From edfc5b21d8df6a4209172b9288405d4c5aff4059 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 25 Jan 2021 16:15:29 +0100 Subject: Fix generating errors on SQL syntax errors, add tests for it --- it_dbi_postgres.class | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'it_dbi_postgres.class') diff --git a/it_dbi_postgres.class b/it_dbi_postgres.class index 1161632..bce0fd9 100644 --- a/it_dbi_postgres.class +++ b/it_dbi_postgres.class @@ -110,11 +110,10 @@ function _query($query, $p) if (!($result = pg_query($this->_link, $query)) && $p['safety']) { - /* TODO - $errno = mysqli_errno($this->_link); - if (($p['safety'] < 2) && ($errno == 1062)) # Duplicate entry - return false; + if (($p['safety'] < 2) && it::match('duplicate key value', pg_last_error($this->_link))) # Duplicate entry + return null; + /* TODO if ($errno == 2006) # mysql server has gone away: retry { it::log('sqllog', "it_dbi(): reconnecting mysqli_connect {$p['server']}, {$p['db']}"); -- cgit v1.2.3