I have some PHP code, roughly as follows (ignoring error handling):

$dbh = new SQLite3 ('/path/to/mydb');
$res = $dbh->query ('select a,b,c from mytable where d=23');  // for example

while  (true)
     {

     $reg = $res->fetchArray (SQLITE3_ASSOC);
     if  ($reg===false)  break;

     // process results here (for each row)

     }

$dbh = null;


Now I'm finding that sometimes the "processing results here" can take a minute 
or so, as it involves reading a file from disk and sending it to a remote host. 
Instead of twiddling my thumbs waiting for this, I'm initiating another action 
which inter alia involves doing an insert into mytable in mydb, and yes, it 
gets "database is locked".

A simple way to fix this is to read the results into arrays in my loop above 
(should be quick, rarely more than 10 rows), drop the database, and then have a 
second loop to use the results, i.e. move "process results here" into the 
second loop.

But can I instead move setting the handle to null right after the query? Or 
does that lose me the result set?

--
Cheers  --  Tim
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to