Skip to content

Commit af01f45

Browse files
committed
fixed: Error when using PHP8
dokuwiki\Exception\FatalException: Declaration of MDB3::query($sql, $params = null) must be compatible with PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs): PDOStatement|false
1 parent d505553 commit af01f45

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

DB.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ class MDB3 extends PDO {
1717
function __construct($dsn, $username="", $password="", $driver_options=array()) {
1818
parent::__construct($dsn,$username,$password, $driver_options);
1919
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MDB3Statement', array($this)));
20+
$this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
2021
}
21-
function query($sql, $params = NULL) {
22+
function query($sql, $mode = null, ...$params) {
2223
global $ALOCAL;
2324

2425
if ($ALOCAL['debug']) error_log($sql, 3, '/tmp/php.log');
@@ -30,10 +31,6 @@ function getAll($query) {
3031
$stmt = $this->query($query);
3132
return $stmt->fetchAll();
3233
}
33-
function setFetchMode($mode) {
34-
if (DB_FETCHMODE_ASSOC === $mode)
35-
$this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
36-
}
3734
function setOption($option,$val) {
3835
if ('persistent' === $option)
3936
$this->setAttribute(PDO::ATTR_PERSISTENT, $val);

syntax.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ function render($mode, Doku_Renderer $renderer, $data) {
128128
$db =& array_pop($this->databases);
129129
if (!empty($db)) {
130130
foreach ($data['sql'] as $query) {
131-
$db->setFetchMode(DB_FETCHMODE_ASSOC);
132131
try {
133132
$result =& $db->getAll($query);
134133
} catch(Exception $e) {

0 commit comments

Comments
 (0)