From 3689fbd3aef7f98a8fe622a5fc278ff9707043f2 Mon Sep 17 00:00:00 2001 From: Martijn de Boer Date: Sun, 10 Nov 2024 14:24:47 +0100 Subject: [PATCH] Readonly mode DB --- lib/Database.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Database.php b/lib/Database.php index df58aec..de5342d 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -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",