Skip to content

Commit

Permalink
Fixes ADOdb#978 for ADOdb 5.21x
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanGibbs3 committed Jun 11, 2023
1 parent c3e6a36 commit 38057ff
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions drivers/adodb-postgres8.inc.php
Expand Up @@ -47,9 +47,21 @@ class ADODB_postgres8 extends ADODB_postgres7
*/
protected function _insertID($table = '', $column = '')
{
return empty($table) || empty($column)
? $this->GetOne("SELECT lastval()")
: $this->GetOne("SELECT currval(pg_get_serial_sequence('$table', '$column'))");
global $ADODB_GETONE_EOF;

$sql = empty($table) || empty($column)
? 'SELECT lastval()'
: "SELECT currval(pg_get_serial_sequence('$table', '$column'))";

// Squelch "ERROR: lastval is not yet defined in this session" (see #978)
$result = @$this->GetOne($sql);
if ($result === false || $result == $ADODB_GETONE_EOF) {
if ($this->debug) {
ADOConnection::outp(__FUNCTION__ . "() failed : " . $this->errorMsg());
}
return false;
}
return $result;
}
}

Expand Down

0 comments on commit 38057ff

Please sign in to comment.