READONLY check

This commit is contained in:
Martijn de Boer 2024-11-10 14:44:47 +01:00
parent 3689fbd3ae
commit 8c01f072c2

View file

@ -3,14 +3,14 @@ class Database
{ {
public static $handle = null; public static $handle = null;
public function __construct($createDatabase = false, bool $readonly = false) public function __construct($createDatabase = false)
{ {
if (self::$handle === null) { if (self::$handle === null) {
self::$handle = new SQLite3(SQLITE_DB); self::$handle = new SQLite3(SQLITE_DB);
self::$handle->enableExceptions(true); self::$handle->enableExceptions(true);
self::$handle->busyTimeout(60000); self::$handle->busyTimeout(60000);
if ($readonly === true) { if (!defined("READONLY")) {
self::$handle->exec("PRAGMA read_uncommitted = true"); self::$handle->exec("PRAGMA read_uncommitted = true");
return; return;
} }