diff options
-rw-r--r-- | it_dbi.class | 2 | ||||
-rw-r--r-- | it_dbi_postgres.class | 5 | ||||
-rwxr-xr-x | test/it_dbi.t | 1 |
3 files changed, 5 insertions, 3 deletions
diff --git a/it_dbi.class b/it_dbi.class index d8dfa1b..6268105 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -579,7 +579,7 @@ function query($query, $p = array()) if (!($result = $this->_query($query, $p))) { - if ($result === null) + if ($result === null || !$p['safety']) return false; $this->_fatal("query(\"$query\") failed"); } diff --git a/it_dbi_postgres.class b/it_dbi_postgres.class index 5caaba9..c26f5fc 100644 --- a/it_dbi_postgres.class +++ b/it_dbi_postgres.class @@ -108,7 +108,7 @@ function _query($query, $p) $query .= ' RETURNING ' . $this->_escape_name($this->_p['keyfield']); } - if (!($result = pg_query($this->_link, $query)) && $p['safety']) + if (!($result = @pg_query($this->_link, $query)) && $p['safety']) { if (($p['safety'] < 2) && it::match('duplicate key value', pg_last_error($this->_link))) # Duplicate entry return null; @@ -122,7 +122,8 @@ function _query($query, $p) } */ } - else + + if ($result) { $this->_affectedrows = pg_affected_rows($result); $this->_insertid = $isinsert ? $this->_fetch_assoc($result)[$this->_p['keyfield']] : 0; diff --git a/test/it_dbi.t b/test/it_dbi.t index 7b1c9d7..13708e2 100755 --- a/test/it_dbi.t +++ b/test/it_dbi.t @@ -35,6 +35,7 @@ $opts['subclass']::createclass(['table' => "it_dbi_test", 'forcecreate' => true] $record = new it_dbi_test; $GLOBALS['it_defaultconfig']['fatal_throws_exception'] = true; +is($record->query("SYNTAX ERROR", ['safety' => 0]), false, "Suppress failures with safety 0"); try { is(@$record->select("SYNTAX ERROR"), "Exception", "Syntax triggers exception for fatal_throws_exception mode"); } catch (Exception $e) { |