ID:               32724
 Updated by:       [EMAIL PROTECTED]
 Reported By:      victor-php at boivie dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         SQLite related
 Operating System: Not important
 PHP Version:      5.0.4
 New Comment:

$res = null;

not good enough?


Previous Comments:
------------------------------------------------------------------------

[2005-04-15 21:11:52] victor-php at boivie dot com

Description:
------------
This is a function FEATURE REQUEST and not a real bug. But it's SQLite
related so I put it there instead.

When you start a transaction and want to do a SELECT and then an UPDATE
(for example), the results from the SELECT-query must be finished before
you are allowed to UPDATE (due to the table locking)

This means that you must step through all rows of the resultset (until
the sqlite_fetch_xxx returns false). In some cases, it would be good to
prematurely finish a SELECT-resultset to be able to do an UPDATE without
having to loop through all remaining rows. 

Thus, a sqlite_free_result() function would be useful.

Reproduce code:
---------------
 $db = sqlite_open("test.db");

 sqlite_exec($db, "BEGIN TRANSACTION");
 $res = sqlite_unbuffered_query($db, "SELECT * FROM temp");
 $row = sqlite_fetch_array($res);

 sqlite_exec($db, "UPDATE temp SET value=10 WHERE id=1");
 sqlite_exec($db, "END TRANSACTION");

 sqlite_close($db);


Expected result:
----------------
Well, I expect it to fail. 

With a sqlite_free_result($res) after the sqlite_fetch_array-statement
I would expect it to work. 

A workaround is, (after you have retrieved your important results from
the SELECT), to do a 

while (sqlite_fetch_array($res));

... to step through the remaining rows.

Actual result:
--------------
Well, it fails as I expected.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32724&edit=1

Reply via email to