From dc94fa1cd5fc57a892ea94641f16d04e5eb4a558 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 28 Jul 2017 15:52:37 +0900 Subject: [PATCH] PG class updates, basic class updates In basic class, do SET_SESSION_NAME check with isset to avoid notice log entries. Change log/error return for execute data error base postgresql calss calls set the last run query on error if no result is returned for prepare and execute --- www/libs/Class.Basic.inc | 2 +- www/libs/Class.DB.IO.inc | 3 ++- www/libs/db_pgsql.inc | 10 ++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/www/libs/Class.Basic.inc b/www/libs/Class.Basic.inc index d9e38c05..755c7ef2 100644 --- a/www/libs/Class.Basic.inc +++ b/www/libs/Class.Basic.inc @@ -312,7 +312,7 @@ if (!session_id()) { // check if we have an external session name given, else skip this step - if (SET_SESSION_NAME) + if (isset(SET_SESSION_NAME)) { // set the session name for possible later check $this->session_name = SET_SESSION_NAME; diff --git a/www/libs/Class.DB.IO.inc b/www/libs/Class.DB.IO.inc index e622f191..b08a5670 100644 --- a/www/libs/Class.DB.IO.inc +++ b/www/libs/Class.DB.IO.inc @@ -1530,7 +1530,8 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[ // failed to get insert id $this->insert_id = ''; $this->warning_id = 33; - $this->_db_error('db', 'DB-Warning '.$stm_name.': insert id returned no data', 'DB_WARNING'); + $this->_db_error(); + $this->_db_debug('db', 'DB-Warning '.$stm_name.': insert id returned no data', 'DB_WARNING'); } } // this error handling is only for pgsql diff --git a/www/libs/db_pgsql.inc b/www/libs/db_pgsql.inc index e3845f03..98c8da9d 100644 --- a/www/libs/db_pgsql.inc +++ b/www/libs/db_pgsql.inc @@ -112,7 +112,10 @@ // DESC : wrapper for pg_prepare public function _db_prepare($name, $query) { - return @pg_prepare($this->dbh, $name, $query); + $result = @pg_prepare($this->dbh, $name, $query); + if (!$result) + $this->last_error_query = $query; + return $result; } // METHOD: _db_execute @@ -121,7 +124,10 @@ // DESC : wrapper for pg_execute for running a prepared statement public function _db_execute($name, $data) { - return @pg_execute($this->dbh, $name, $data); + $result = @pg_execute($this->dbh, $name, $data); + if (!$result) + $this->last_error_query = $query; + return $result; } // METHOD: _db_num_rows