|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-07-10 15:18 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 22:00:01 2025 UTC |
Description: ------------ There is no way to ascertain whether an ATTACH command worked, as sqlite_query() and sqlite_unbuffered_query() return FALSE whether it worked or not. HERE'S THE FIX: Upgrading the embedded sqlite from 2.8.11 to 2.8.13 solved this problem (as well as correcting the 2.8.11 bugs, of course). Reproduce code: --------------- <?php /* * We assume that /tmp/test1.db and /tmp/test2.db exist and have the following * schema and data: * * test1.db: * CREATE TABLE t1 (i INTEGER PRIMARY KEY, t TEXT); * INSERT INTO t1 VALUES (23, 'hello'); * * test2.db: * CREATE TABLE t2 (j INTEGER PRIMARY KEY, t TEXT); * INSERT INTO t2 VALUES (42, 'world'); * */ if (($dbConn = sqlite_open("/tmp/test1.db", 0666)) === false) { echo "open test1.db failed<p>"; exit; } if (($dbRC = sqlite_query($dbConn, "ATTACH '/tmp/test2.db' AS test_db;")) === false) { echo "This should have returned TRUE, but returned FALSE. See, it can get data from t2...<br>"; if (! $dbRC = sqlite_query($dbConn, "SELECT j, t FROM t2;")) { echo "Could not retrieve data from t2<br>"; } else { while ($row = @sqlite_fetch_array($dbRC, SQLITE_ASSOC)) { echo "Got j = " . $row["j"] . ", t = " . $row["t"] . "<br>"; } } exit; } echo "ATTACH returned what it should have (this doesn't happen)<br>"; exit; ?> Expected result: ---------------- TRUE Actual result: -------------- FALSE