php , mysql i temporary tables

2 отговора 107 прегледа
#1

php , mysql i temporary tables

Zdraweite ,
Predi nqkolko dena se sbluskah sys sledniq problem:
naloji mi se da naprawq temporary table v mysql , crez php script i s iznenada razbrah , che towa ne stawa (pone ne po standartniq nachin)
Eto kakwo prawa az:
test1.php
........
<?php
include("dbconnect.php");
$query1 = "create temporary table test001 (col1 text)";
mysql_query($query1) or die (mysql_error());
$query2 = "insert into test001 (col1) values ('somestring') ";
mysql_query($query2) or die (mysql_error());
?>
........
Kato dbconnect.php e script koito se wryzwa kym bazata i select-wa baza danni ( w nego nqma problemi)
..
Sled izpylnenieto na scripta , koito se izpylnqwa bez greshki , se poluchawa slednoto w log-a na mysql
.......
031023 20:52:27 13 Connect root@localhost on
13 Init DB test
13 Query create temporary table test001 (col1 text)
13 Query insert into test001 (col1) values ('somestring')
13 Quit
............
E da ama ne
tablica test001 prosto ne syshtestwywa
mysql> select * from test001 ;
ERROR 1146: Table 'test.test001' doesn't exist
Sledwashtoto neshto koeto naprawih beshe da paste-na (bukwalno ) query-tata koito se poqwiha w mysql.log w komandniq red na mysql
mysql> create temporary table test001 (col1 text);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into test001 (col1) values ('somestring');
Query OK, 1 row affected (0.00 sec)
(wsi4ko e Ok do tuk)
mysql> select * from test001;
+------------+
| col1 |
+------------+
| somestring |
+------------+
1 row in set (0.03 sec)
....
e dwe dumi kazano : bachka si
Wyprosa mi e zashto ne iska da raboti sys php script ?


predwaritelno wi blagodarq za sywetite i mneniqta

Отговор
в отговор на O #2

Re: php , mysql i temporary tables

Mi struva mi se che se opitvash da selectnesh sled kato tablicata veche ia niama , t.e. zatvoril si konekciata i tia se e razrsuhila.
A pri primera ot comandnia red si conektnat, taka che tableto si e tam oshte.
Samo predpolagam, ne sam go probval napraktika.

--------------------------------
Fast. Good. Cheap. Pick any two.
Отговор
в отговор на JQ #3

Re: php , mysql i temporary tables

ми то в документацията си пише...
ма някой трябва да чете...

In MySQL Version 3.23, you can use the TEMPORARY keyword when you create a table. A temporary table will automatically be deleted if a connection dies and the name is per connection. This means that two different connections can both use the same temporary table name without conflicting with each other or with an existing table of the same name. (The existing table is hidden until the temporary table is deleted.). In MySQL 4.0.2 one must have the CREATE TEMPORARY TABLES privilege to be able to create temporary tables.

MySQL Reference Manual (C) 2002 MySQL AB

Отговор