From: csaba at alum dot mit dot edu
Operating system: Win 2K Pro
PHP version: 5CVS-2004-05-03 (dev)
PHP Bug Type: SQLite related
Bug description: SQLite not doing multiple queries
Description:
------------
The sqlite_query page in a prominent box declares that SQLite will execute
multiple queries separated by semicolons, but this seems not to be the
case according to the test below. While I posted a workaround for this,
it is not very efficient because you have to send each query separately.
I have tested the command line version of SQLite (2.8.13) and it does
accept multiple queries separated by semicolons.
Also, if dealing with this problem, I'd like to suggest that if the final
query is a SELECT or other statement which produces some result normally
destined for the user, that it be returned to the caller that way. The
documentation makes it seems like maybe it will and maybe it won't, saying
it's undefined. In particular, it would be helpful if SELECT and PRAGMA
returned their results. If you indulge me on that, please extend the
functionality to sqlite_array_query.
Thanks,
Csaba Gabor
Reproduce code:
---------------
$db = sqlite_open(':memory:', 0666, $sqliteerror);
$tbl = "delme";
$multiQuery = "CREATE TABLE $tbl (foo INTEGER PRIMARY KEY, bar TEXT);" .
"INSERT INTO $tbl VALUES (null, 'Hi Mom');";
$dbRes = sqlite_query ($db, $multiQuery);
$creationTest = "PRAGMA table_info('$tbl');";
$insertTest = "SELECT * FROM $tbl;";
$acT = sqlite_array_query ($db, $creationTest, SQLITE_ASSOC);
var_dump ($acT);
print "<br><br>Table was created,<br>";
$aiT = sqlite_array_query ($db, $insertTest, SQLITE_ASSOC);
var_dump ($aiT);
print "<br>but nothing was inserted";
Expected result:
----------------
I expect to that the SQL INSERT statement was carried out
Actual result:
--------------
However, SQL statements after the first ';' seem to be ignored. Thus, the
second var_dump only gets an empty array.
--
Edit bug report at http://bugs.php.net/?id=28264&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28264&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28264&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28264&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28264&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28264&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28264&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28264&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28264&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28264&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28264&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28264&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28264&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28264&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28264&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28264&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28264&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28264&r=float