From d52af6db5a7b3bdde98015578ea917d52fcf545d Mon Sep 17 00:00:00 2001 From: "J. King" Date: Tue, 20 Nov 2018 15:48:03 -0500 Subject: [PATCH] PostgreSQL fixes Errors were not correctly throwing exceptions For the sake of SQLite compatibility booleans should be bound as integers in PDO --- lib/Db/PDOStatement.php | 2 +- lib/Db/PostgreSQL/PDODriver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Db/PDOStatement.php b/lib/Db/PDOStatement.php index cfd9cef..95b95a7 100644 --- a/lib/Db/PDOStatement.php +++ b/lib/Db/PDOStatement.php @@ -15,7 +15,7 @@ class PDOStatement extends AbstractStatement { "datetime" => \PDO::PARAM_STR, "binary" => \PDO::PARAM_LOB, "string" => \PDO::PARAM_STR, - "boolean" => \PDO::PARAM_BOOL, + "boolean" => \PDO::PARAM_INT, // FIXME: using \PDO::PARAM_BOOL leads to incompatibilities with versions of SQLite bundled prior to PHP 7.3 ]; protected $st; diff --git a/lib/Db/PostgreSQL/PDODriver.php b/lib/Db/PostgreSQL/PDODriver.php index 9bb630e..af98338 100644 --- a/lib/Db/PostgreSQL/PDODriver.php +++ b/lib/Db/PostgreSQL/PDODriver.php @@ -22,7 +22,7 @@ class PDODriver extends Driver { protected function makeConnection(string $user, string $pass, string $db, string $host, int $port, string $service) { $dsn = $this->makeconnectionString(true, $user, $pass, $db, $host, $port, $service); - $this->db = new \PDO("pgsql:$dsn", $user, $pass); + $this->db = new \PDO("pgsql:$dsn", $user, $pass, [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]); } public function __destruct() {