Readonly mode DB

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

View file

@ -3,13 +3,18 @@ class Database
{
public static $handle = null;
public function __construct($createDatabase = false)
public function __construct($createDatabase = false, bool $readonly = false)
{
if (self::$handle === null) {
self::$handle = new SQLite3(SQLITE_DB);
self::$handle->enableExceptions(true);
self::$handle->busyTimeout(60000);
if ($readonly === true) {
self::$handle->exec("PRAGMA read_uncommitted = true");
return;
}
$initialQueries = [
"PRAGMA journal_mode = WAL",
"PRAGMA synchronous = OFF",