Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #978 for ADOdb 5.21x #983

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions drivers/adodb-postgres8.inc.php
Original file line number Diff line number Diff line change
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