Skip to content

Commit

Permalink
Potential Close ADOdb#978
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanGibbs3 committed Jun 9, 2023
1 parent d4f9f45 commit bd3885c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions drivers/adodb-postgres8.inc.php
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit bd3885c

Please sign in to comment.