[MDB1] currId() for oci8 driver
| From: | Thierry Bothorel | Date: | Wed, 18 Feb 2004 23:19:52 +0000 |
| Subject: | [MDB1] currId() for oci8 driver | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-10786@lists.php.net to get a copy of this message | ||
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);
}
// }}}
Thierry Bothorel
--
Click here to answer / cliquez ci dessous pour me repondre
http://cerbermail.com/?7O7SOrggJg