note 118837 added to sqlite3.exec
| From: | alexandre dot schmidt at gmail dot com | Date: | Sat, 13 Feb 2016 17:38:13 +0000 |
| Subject: | note 118837 added to sqlite3.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204937@lists.php.net to get a copy of this message | ||
I was getting "database locked" all the time until I found out some features of sqlite3
must be set by using SQL special instructions (i.e. using PRAGMA keyword). For instance, what
apparently solved my problem with "database locked" was to set journal_mode to
'wal' (it is defaulting to 'delete', as stated here: https://www.sqlite.org/wal.html (see Activating And
Configuring WAL Mode)).
So basically what I had to do was creating a connection to the database and setting journal_mode
with the SQL statement. Example:
<?php
$db = new SQLite3('/my/sqlite/file.sqlite3');
$db->busyTimeout(5000);
// WAL mode has better control over concurrency.
// Source: https://www.sqlite.org/wal.html
$db->exec('PRAGMA journal_mode = wal;');
?>
Hope that helps.
----
Server IP: 72.52.91.14
Probable Submitter: 189.10.172.34
----
Manual Page -- http://php.net/manual/en/sqlite3.exec.php
Edit -- https://master.php.net/note/edit/118837
Del: integrated -- https://master.php.net/note/delete/118837/integrated
Del: useless -- https://master.php.net/note/delete/118837/useless
Del: bad code -- https://master.php.net/note/delete/118837/bad+code
Del: spam -- https://master.php.net/note/delete/118837/spam
Del: non-english -- https://master.php.net/note/delete/118837/non-english
Del: in docs -- https://master.php.net/note/delete/118837/in+docs
Del: other reasons-- https://master.php.net/note/delete/118837
Reject -- https://master.php.net/note/reject/118837
Search -- https://master.php.net/manage/user-notes.php