note 54143 deleted from function.pdo-query by dbs
| From: | dbs@php.net | Date: | Wed, 19 Oct 2005 19:44:35 +0000 |
| Subject: | note 54143 deleted from function.pdo-query by dbs | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-97245@lists.php.net to get a copy of this message | ||
Note Submitter: schmeic-php at lovo dot org
----
Note that if you are using the sqlite3 driver, you need to fetch all data before sqlite3 will unlock
the db. sqlite3 allows multiple readers, but writes require an exclusive lock. Consider the
following code:
<?php
$pdo = new PDO("sqlite:/path/dbfile");
$query = "select * from some_table";
$pdo_statement1 = $pdo->query($query);
$query = "update some_table set some_field = some_value";
$pdo_statement2 = $pdo->query($query);
?>
The second query will fail and if you check out the driver specific error message, you will see
that the db is locked.
So before you can do the update, you'll need to fetch all the data. If you put this code
between the two queries, the update will work.
<?php
$all_select_data = $pdo_statement1->fetchAll();
?>