Home » Database » MDB » Bug #801
currId() for oci8 driver
Details
| Submitted | 2004-02-19 17:51 UTC |
|---|---|
| From | thierry dot bo at netcourrier dot com |
| Assigned | lsmith |
| Status | Closed |
| Package | MDB |
| PHP Version | 4.3.2 |
| OS | win32XP |
| Roadmaps | (Not assigned) |
Comments
[2004-02-19 17:51 UTC] thierry dot bo at netcourrier dot com
Description:
------------
Hi,
I see oci8 driver (v 1.21.4.11) does not implement the currId() function, so
the one in common.php is used, and this one use nextId(), so code using
currId is broken for use with several databases.
Since there is a native oracle function to get the current sequence value,
why not add this simple function in oci8.php (merely a copy/paste from the
pgsql driver) that works for me ?
// {{{ currId()
/**
* returns the current id of a sequence
*
* @param string $seq_name name of the sequence
* @return mixed MDB_Error or id
* @access public
*/
function currId($seq_name)
{
$seqname = $this->getSequenceName($seq_name);
if (MDB::isError($result = $this->queryOne("SELECT $seqname.currval FROM DUAL"))) {
return($this->raiseError(MDB_ERROR, NULL, NULL, 'currId: Unable to select from ' . $seqname) );
}
if (!is_numeric($result)) {
return($this->raiseError(MDB_ERROR, NULL, NULL, 'currId: could not find
value in sequence table'));
}
return($result);
}
// }}}