From 858aea023d069661e40511df42cda80dc4181044 Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Sun, 27 Jun 2021 15:44:21 +0300 Subject: [PATCH] - rewrite sqlite3 table_exists() to avoid error in PHP 8 --- src/includes/class.db.sqlite3.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/includes/class.db.sqlite3.php b/src/includes/class.db.sqlite3.php index 950e65d..5cc47bb 100644 --- a/src/includes/class.db.sqlite3.php +++ b/src/includes/class.db.sqlite3.php @@ -152,10 +152,15 @@ class Database_Sqlite3 function table_exists($table) { - $table = $this->dbh->quote($table); - $q = $this->dbh->query("SELECT 1 FROM $table WHERE 1=0"); - if($q === false) return false; - else return true; + $exists = $this->sq("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?", $table); + if ($exists == "1") { + return true; + } + $exists = $this->sq("SELECT 1 FROM sqlite_temp_master WHERE type='table' AND name=?", $table); + if ($exists == "1") { + return true; + } + return false; } }