added table and colum as parameter to Insert_ID() to correctly retrive the id under postgres and MaxDB

This commit is contained in:
Ralf Becker
2004-08-03 23:03:38 +00:00
parent 1ef5e6e3ad
commit 5f8de74a2a
2 changed files with 9 additions and 5 deletions

View File

@ -150,10 +150,12 @@ WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s'))
Using a OID as a unique identifier is not generally wise.
Unless you are very careful, you might end up with a tuple having
a different OID if a database must be reloaded. */
function _insertid()
function _insertid($table,$column)
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
return pg_getlastoid($this->_resultid);
$oid = pg_getlastoid($this->_resultid);
// to really return the id, we need the table and column-name, else we can only return the oid != id
return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid);
}
// I get this error with PHP before 4.0.6 - jlim