From f797f49aebfc346623e875fb544a1aede5c5bbd6 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 4 Jul 2016 12:44:34 +1200 Subject: [PATCH] BUG Fix pg_query / pg_query_params not correctly raising exceptions on error --- code/PostgreSQLConnector.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/PostgreSQLConnector.php b/code/PostgreSQLConnector.php index 7e8fee9..5619f93 100644 --- a/code/PostgreSQLConnector.php +++ b/code/PostgreSQLConnector.php @@ -221,14 +221,16 @@ class PostgreSQLConnector extends DBConnector } // Execute query + // Unfortunately error-suppression is required in order to handle sql errors elegantly. + // Please use PDO if you can help it if (!empty($parameters)) { - $result = pg_query_params($this->dbConn, $sql, $parameters); + $result = @pg_query_params($this->dbConn, $sql, $parameters); } else { - $result = pg_query($this->dbConn, $sql); + $result = @pg_query($this->dbConn, $sql); } // Handle error - if ($result === false) { + if (!$result) { $this->databaseError($this->getLastError(), $errorLevel, $sql, $parameters); return null; }