database table is locked

Print
If you write a program a little bit complicated in PHP using PDO SQLite3 and you have certainly been confronted with this problem.
An error like: 'database table is locked'

PDO requires absolutely empty query results.
For example, if you run a select query whose result contains 15 lines, so that you do not recover all these lines the table is 'locked'.

To avoid this problem, there are two solutions:
- The first is to use only 'fetchAll' to retrieve results.
$ res = $ connid-> query ( 'SELECT * FROM database;');
$ tabResult = $ res-> fetchAll ();


- The second, which is used in SQLiteManager 1.2.0! ; Before executing a new query, we check whether the result object exists, in which case it executes 'closeCursor' on it
if (is_object ($ res)) $ res-> closeCursor ();