On 5 Apr 2012, at 3:15pm, Richard Hipp <d...@sqlite.org> wrote:

> Probably the $r query is not being finalized, and is thus holding the read
> lock, preventing the subsequent write from happening.  You shouldn't have
> to close the connection in order to finalize the query - but I don't know
> the PHP syntax for finalizing the query without closing the connection.

The appropriate finalize method exists.  The correct way to use the SQLite3 
routines for a SELECT is (quickly made up from the top of my head, untested) ...

    try {
        $result = db->query($theCommand);
    } catch (Exception $e) {
        die('Error while executing ' .$theCommand. ': '. $e->getMessage());
    }

    while ($thisRow = $result->fetchArray(SQLITE3_ASSOC)) {
        ... do something with $thisRow ...
    }
    $result->finalize();

And now you point it out, I see that the OP has indeed forgotten to finalize 
his result set in his PHP code, so the SELECT never finishes.

The PHP SQLite3 API is a very thin wrapper around the C++ API.  I found that 
knowing one of them well, I could easily find an exact equivalent function in 
the other.  This is not the same as the other two ways of accessing SQLite 
databases available to PHP users, which try to standardise across many database 
engines so they are futher away from what someone familiar with SQLite would 
expect to see.

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

Reply via email to