mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
added table and colum as parameter to Insert_ID() to correctly retrive the id under postgres and MaxDB
This commit is contained in:
parent
1ef5e6e3ad
commit
5f8de74a2a
@ -902,12 +902,14 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $table string name of the table, not needed by all databases (eg. mysql), default ''
|
||||
* @param $column string name of the column, not needed by all databases (eg. mysql), default ''
|
||||
* @return the last inserted ID. Not all databases support this.
|
||||
*/
|
||||
function Insert_ID()
|
||||
function Insert_ID($table='',$column='')
|
||||
{
|
||||
if ($this->_logsql && $this->lastInsID) return $this->lastInsID;
|
||||
if ($this->hasInsertID) return $this->_insertid();
|
||||
if ($this->hasInsertID) return $this->_insertid($table,$column);
|
||||
if ($this->debug) {
|
||||
ADOConnection::outp( '<p>Insert_ID error</p>');
|
||||
adodb_backtrace();
|
||||
@ -925,7 +927,7 @@
|
||||
function PO_Insert_ID($table="", $id="")
|
||||
{
|
||||
if ($this->hasInsertID){
|
||||
return $this->Insert_ID();
|
||||
return $this->Insert_ID($table,$id);
|
||||
} else {
|
||||
return $this->GetOne("SELECT MAX($id) FROM $table");
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user