diff options
author | Simon Rettberg | 2020-02-27 10:32:16 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-02-27 10:32:16 +0100 |
commit | a437efbbb5f40e95e6a3ec75dc0da042a83d5f74 (patch) | |
tree | 2c6ae5cffc0ae6e29dbfa12e02cb4180f6e83554 /inc/database.inc.php | |
parent | [minilinux] Update translations (diff) | |
download | slx-admin-a437efbbb5f40e95e6a3ec75dc0da042a83d5f74.tar.gz slx-admin-a437efbbb5f40e95e6a3ec75dc0da042a83d5f74.tar.xz slx-admin-a437efbbb5f40e95e6a3ec75dc0da042a83d5f74.zip |
[inc/Database] Convert bool params to 1 or 0
PDO unfortunately only does (string)<bool> for boolean params, which
converts false to '' instead of '0'. This breaks MariaDB in strict mode.
Diffstat (limited to 'inc/database.inc.php')
-rw-r--r-- | inc/database.inc.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/inc/database.inc.php b/inc/database.inc.php index 3b2414b5..7d9cbce3 100644 --- a/inc/database.inc.php +++ b/inc/database.inc.php @@ -141,6 +141,15 @@ class Database // Support passing nested arrays for IN statements, automagically refactor $oquery = $query; self::handleArrayArgument($query, $args); + // Now turn any bools into 0 or 1, since PDO unfortunately only does (string)<bool>, which + // results in an empty string for false + foreach ($args as &$arg) { + if ($arg === false) { + $arg = '0'; + } elseif ($arg === true) { + $arg = '1'; + } + } try { if (!isset(self::$statements[$query])) { self::$statements[$query] = self::$dbh->prepare($query); |