I'm using this constant loop standalone script to get data from SQLite3 db. Once in a while script exits with fatal error:
PHP Warning: SQLite3::query(): Unable to prepare statement: 14, unable to open database file in /home/alex/looper.php on line 17
PHP Fatal error: Call to a member function fetchArray() on a non-object in /home/alex/looper.php on line 19
There is no much data in that db, maybe 10-50 rows total. Not sure where to start looking. Please help.
Code:
function listen() {
$db = new SQLite3("/home/alex/some.db");
$result = $db->query("SELECT * FROM names where status=0");
while($row = $result->fetchArray()) {
// .... do some stuff and delete record
$db->query("DELETE FROM names WHERE id='$row[id]'");
}
sleep(3);
listen();
}
set_time_limit(0);
listen();