diff options
| author | Damien Regad <dregad@mantisbt.org> | 2023-06-11 01:50:11 +0200 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2023-06-11 01:50:11 +0200 |
| commit | 348d2631724b3e72e45b9785fa679ca064098e93 (patch) | |
| tree | 7d342cf52806e69154cfff309e262d969755a253 /drivers | |
| parent | b819440c251b1d916b663a91e32ac9eae2eaf57f (diff) | |
| download | adodb-348d2631724b3e72e45b9785fa679ca064098e93.tar.gz adodb-348d2631724b3e72e45b9785fa679ca064098e93.tar.bz2 adodb-348d2631724b3e72e45b9785fa679ca064098e93.zip | |
PR #779 follow-up
- Add missing global var declaration
- Coding guidelines
- Comment usage of @ operator
- Update changelog
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/adodb-postgres8.inc.php | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/adodb-postgres8.inc.php b/drivers/adodb-postgres8.inc.php index 911ec178..58df47c6 100644 --- a/drivers/adodb-postgres8.inc.php +++ b/drivers/adodb-postgres8.inc.php @@ -45,13 +45,19 @@ 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 = '' ){ - $sql = 'SELECT '; - $sql .= empty($table) || empty($column) ? 'lastval()' : "currval(pg_get_serial_sequence('$table', '$column'))"; + protected function _insertID( $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()); + if ($result === false || $result == $ADODB_GETONE_EOF) { + if ($this->debug) { + ADOConnection::outp(__FUNCTION__ . "() failed : " . $this->errorMsg()); } return false; } |
