PHP supports the use of persistent SQLite connections. However, a problem arises in trying to run maintenance scripts (like a file backup), with such a connection opened. These scripts are likely to be run without a server restart every now and then, in periods of low traffic.
How can I check if there is currently an SQLite persistent connection, without opening / calling one (hence creating the connection)?
See: php SQLite persistent connection
If you use PDO you can just check if the handler is null or not before you run the maintenance scripts. That way you wont be creating a connection like with sqlite_popen()
Create a persistent connection with PDO if you want: $handler = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_PERSISTENT => TRUE));
...Then you can just close the connection before the maintenance script is called, assuming it is on some sort of schedule:
if(!is_null($handler)){
$handler = null;
//run maintenance script, recreate connection once finished
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With