mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
* avoid sqlite deprecation notices in PHP 8.5
This commit is contained in:
parent
d0b19e59a6
commit
e00ae3d1dd
1 changed files with 16 additions and 6 deletions
|
|
@ -58,7 +58,7 @@ class Database_Sqlite3 extends Database_Abstract
|
||||||
{
|
{
|
||||||
const DBTYPE = 'sqlite';
|
const DBTYPE = 'sqlite';
|
||||||
|
|
||||||
/** @var PDO */
|
/** @var PDO|\Pdo\Sqlite */
|
||||||
protected $dbh;
|
protected $dbh;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
|
|
@ -82,11 +82,21 @@ class Database_Sqlite3 extends Database_Abstract
|
||||||
$options = array(
|
$options = array(
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||||
);
|
);
|
||||||
$this->dbh = new PDO("sqlite:$filename", null, null, $options); //throws PDOException
|
if (PHP_VERSION_ID < 70500) {
|
||||||
$this->dbh->sqliteCreateFunction('utf8_lower', [$this, 'utf8_lower'], 1);
|
$this->dbh = new PDO("sqlite:$filename", null, null, $options); //throws PDOException
|
||||||
$this->dbh->sqliteCreateFunction('utf8_normalized_lower', [$this, 'utf8_normalized_lower'], 1);
|
# Deprecated since PHP 8.5
|
||||||
$this->dbh->sqliteCreateCollation('UTF8CI', [$this, 'collate_utf8ci']);
|
$this->dbh->sqliteCreateFunction('utf8_lower', [$this, 'utf8_lower'], 1);
|
||||||
$this->dbh->sqliteCreateCollation('UTF8CI_NORMALIZED', [$this, 'collate_utf8ci_normalized']);
|
$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']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue