* avoid sqlite deprecation notices in PHP 8.5

This commit is contained in:
maxpozdeev 2026-01-03 14:24:04 +03:00
parent d0b19e59a6
commit e00ae3d1dd

View file

@ -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']);
}
}
/*