Browse Source

PostgreSQL fixes

Errors were not correctly throwing exceptions

For the sake of SQLite compatibility booleans should be bound as
integers in PDO
microsub
J. King 5 years ago
parent
commit
d52af6db5a
  1. 2
      lib/Db/PDOStatement.php
  2. 2
      lib/Db/PostgreSQL/PDODriver.php

2
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;

2
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() {

Loading…
Cancel
Save