ID: 27911 Updated by: [EMAIL PROTECTED] Reported By: csaba at alum dot mit dot edu -Status: Open +Status: Feedback Bug Type: SQLite related Operating System: Win 2K PHP Version: 5.0.0RC1 New Comment:
Please try using the full path to the file in your ATTACH SQL. PS: it's SQLite, not mysqlite Previous Comments: ------------------------------------------------------------------------ [2004-04-07 17:29:27] csaba at alum dot mit dot edu Description: ------------ I've been using mysqlite regularly for the past two weeks, no complaints. However, I cannot seem to do a SQLite ATTACH DATABASE at all. Variations I have tried: sqlite_popen in place of sqlite_open (especially when $db1 was ':memory:', closing $db1 before attaching, using ':memory:' in place of either 'Delme1.db1' or 'Delme2.db1'. I have also tried this with and without open_basedir set to "." in my Apache 2.0.48 Csaba Gabor Reproduce code: --------------- $db1 = sqlite_open('Delme.db1', 0666, $sqliteerror); sqlite_query ($db1, 'DROP TABLE Tab1;'); sqlite_query($db1, "CREATE TABLE Tab1 (Id INTEGER PRIMARY KEY, Fld1 VARCHAR(16));"); sqlite_query ($db1, "INSERT INTO Tab1 VALUES (NULL, 'foo1');"); print "<br>Rows: in DB1: " . sqlite_fetch_single (sqlite_query($db1, "SELECT COUNT(*) FROM Tab1;")); $db2 = sqlite_open('Delme.db2', 0666, $sqliteerror); sqlite_query ($db2, 'DROP TABLE Tab2;'); sqlite_query($db2, "CREATE TABLE Tab2 (Id2 INTEGER PRIMARY KEY, Fld2 VARCHAR(8));"); sqlite_query ($db2, "INSERT INTO Tab2 VALUES (NULL, 'bar2');"); sqlite_query ($db2, "INSERT INTO Tab2 VALUES (NULL, 'bar3');"); print "<br>Rows in DB2: " . sqlite_fetch_single (sqlite_query($db2, "SELECT COUNT(*) FROM Tab2;")); @sqlite_query ($db2, "DETACH DATABASE db;"); sqlite_query ($db2, "ATTACH DATABASE 'Delme.db1' AS db4;"); $aRes = sqlite_array_query ($db2, "SELECT * FROM db4.Tab1;"); Expected result: ---------------- I expect that I can use the attached database as described at SQLite's homepage. Actual result: -------------- Instead, in pretty much all the variants that I tried, I get the following error on the ATTACH DATABASE line: Warning: sqlite_query() [function.sqlite-query]: cannot attach empty database: db4 in MyPHPFilesDir/myPHPCode.php on line 15 The following (last) line also gets a complaint but by then the damage has already been done. At some point, when I was testing using db3 (in place of where db4 now is), I got the complaint that the database (db3) was already in use. I don't know how that complaint started originating, nor could I get rid of it. Going to db4 got me back to the usual complaint I indicated above. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27911&edit=1