Skip to content

Commit 458c2ac

Browse files
authored
Merge pull request #70 from superdav42/fix/php85-deprecated-sqliteCreateFunction
2 parents 5d8af6b + 1dd07a5 commit 458c2ac

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/db.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ public function __construct($pdo)
152152
wp_die('Database is not initialized.', 'Database Error');
153153
}
154154
foreach ($this->functions as $f => $t) {
155-
$pdo->sqliteCreateFunction($f, [$this, $t]);
155+
if (PHP_VERSION_ID >= 80400) {
156+
$pdo->createFunction($f, [$this, $t]);
157+
} else {
158+
$pdo->sqliteCreateFunction($f, [$this, $t]);
159+
}
156160
}
157161
}
158162

@@ -1163,7 +1167,11 @@ function __construct()
11631167
$status = 0;
11641168
do {
11651169
try {
1166-
$this->pdo = new PDO($dsn, null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
1170+
if (PHP_VERSION_ID >= 80400) {
1171+
$this->pdo = new \Pdo\Sqlite($dsn, null, null, [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
1172+
} else {
1173+
$this->pdo = new PDO($dsn, null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
1174+
}
11671175
new PDOSQLiteUDFS($this->pdo);
11681176
$GLOBALS['@pdo'] = $this->pdo;
11691177
} catch (PDOException $ex) {

0 commit comments

Comments
 (0)