From 00738f502bd5a18a738929c7204484748bc507d3 Mon Sep 17 00:00:00 2001 From: Nathan Gibbs Date: Fri, 9 Jun 2023 23:19:14 +0000 Subject: [PATCH] Potential Close #978 --- drivers/adodb-postgres8.inc.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/adodb-postgres8.inc.php b/drivers/adodb-postgres8.inc.php index 37c2aae14..9a71adaed 100644 --- a/drivers/adodb-postgres8.inc.php +++ b/drivers/adodb-postgres8.inc.php @@ -45,11 +45,26 @@ class ADODB_postgres8 extends ADODB_postgres7 * @return int last inserted ID for given table/column, or the most recently * returned one if $table or $column are empty */ - protected function _insertID($table = '', $column = '') - { - return empty($table) || empty($column) - ? $this->GetOne("SELECT lastval()") - : $this->GetOne("SELECT currval(pg_get_serial_sequence('$table', '$column'))"); + protected function _insertID( $table = '', $column = '' ){ + $Ret = false; + $tmpsql = 'SELECT '; + if( empty($table) || empty($column) ){ + $tmpsql .= 'lastval()'; + }else{ + $tmpsql .= "currval(pg_get_serial_sequence('$table', '$column'))"; + } + $result = @$this->GetOne($tmpsql); + if( $result === false || $result == $ADODB_GETONE_EOF ){ + $Ret = false; + if( $this->debug ){ + ADOConnection::outp( + __FUNCTION__"() failed : " . $this->errorMsg() + ); + } + }else{ + $Ret = $result; + } + return $Ret; } }