PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » MDB2 » Bug #9107

currID using wrong method to get last value of sequence

Details

Submitted2006-10-20 13:35 UTC
Frommcraig at leadehealth dot com
Assignedlsmith
StatusClosed
PackageMDB2
PHP Version4.4.3
OSlinux 2.6
Roadmaps(Not assigned)

Comments

[2006-10-20 13:35 UTC] mcraig at leadehealth dot com

Description:
------------
This code from "function currID()" in MDB2_Driver_pgsql is using last_value of a sequence which is not connection specific within PostgreSQL:

return $this->queryOne("SELECT last_value FROM $sequence_name",'integer');

"last_value" will return the globally unique last value as the whole database sees it.

return $this->queryOne("SELECT currval(<seqname>)", 'integer');

is the correct way to get the connection specific Postgres sequence value.

This bug was also appearing in DataObject and fixed in this manner as seen in this pear-dev thread:
http://www.codecomments.com/message1086631.html

[2006-10-20 14:12 UTC] mcraig at leadehealth dot com

do you already have a lastInsertID() in mind? Could this use the fix proposed for currID?

function lastInsertID($table = null, $field = null)
{
$sequence_name =
$this->quoteIdentifier($this->getSequenceName($table), true);
return $this->queryOne("SELECT currval('$sequence_name')", 'integer');
}

[darn 60 col textarea]