diff --git a/src/includes/class.db.sqlite3.php b/src/includes/class.db.sqlite3.php index 9f38d8b..9303c4a 100644 --- a/src/includes/class.db.sqlite3.php +++ b/src/includes/class.db.sqlite3.php @@ -58,7 +58,7 @@ class Database_Sqlite3 extends Database_Abstract { const DBTYPE = 'sqlite'; - /** @var PDO */ + /** @var PDO|\Pdo\Sqlite */ protected $dbh; /** @var int */ @@ -82,11 +82,21 @@ class Database_Sqlite3 extends Database_Abstract $options = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ); - $this->dbh = new PDO("sqlite:$filename", null, null, $options); //throws PDOException - $this->dbh->sqliteCreateFunction('utf8_lower', [$this, 'utf8_lower'], 1); - $this->dbh->sqliteCreateFunction('utf8_normalized_lower', [$this, 'utf8_normalized_lower'], 1); - $this->dbh->sqliteCreateCollation('UTF8CI', [$this, 'collate_utf8ci']); - $this->dbh->sqliteCreateCollation('UTF8CI_NORMALIZED', [$this, 'collate_utf8ci_normalized']); + if (PHP_VERSION_ID < 70500) { + $this->dbh = new PDO("sqlite:$filename", null, null, $options); //throws PDOException + # Deprecated since PHP 8.5 + $this->dbh->sqliteCreateFunction('utf8_lower', [$this, 'utf8_lower'], 1); + $this->dbh->sqliteCreateFunction('utf8_normalized_lower', [$this, 'utf8_normalized_lower'], 1); + $this->dbh->sqliteCreateCollation('UTF8CI', [$this, 'collate_utf8ci']); + $this->dbh->sqliteCreateCollation('UTF8CI_NORMALIZED', [$this, 'collate_utf8ci_normalized']); + } + else { + $this->dbh = new \Pdo\Sqlite("sqlite:$filename", null, null, $options); //throws PDOException + $this->dbh->createFunction('utf8_lower', [$this, 'utf8_lower'], 1); + $this->dbh->createFunction('utf8_normalized_lower', [$this, 'utf8_normalized_lower'], 1); + $this->dbh->createCollation('UTF8CI', [$this, 'collate_utf8ci']); + $this->dbh->createCollation('UTF8CI_NORMALIZED', [$this, 'collate_utf8ci_normalized']); + } } /*