cvs: pear /MDB2/MDB2/Driver oci8.php

From: Date: Fri, 20 Oct 2006 15:15:21 +0000
Subject: cvs: pear /MDB2/MDB2/Driver oci8.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42680@lists.php.net to get a copy of this message
lsmith Fri Oct 20 15:15:21 2006 UTC Modified files: /pear/MDB2/MDB2/Driver oci8.php Log: - fix the incorrect use of currID() for lastInsertID() emulation (Bug #9107) http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/oci8.php?r1=1.180&r2=1.181&diff_format=u Index: pear/MDB2/MDB2/Driver/oci8.php diff -u pear/MDB2/MDB2/Driver/oci8.php:1.180 pear/MDB2/MDB2/Driver/oci8.php:1.181 --- pear/MDB2/MDB2/Driver/oci8.php:1.180 Sat Oct 14 13:42:02 2006 +++ pear/MDB2/MDB2/Driver/oci8.php Fri Oct 20 15:15:21 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.180 2006/10/14 13:42:02 lsmith Exp $ +// $Id: oci8.php,v 1.181 2006/10/20 15:15:21 lsmith Exp $ /** * MDB2 OCI8 driver @@ -914,6 +914,25 @@ } // }}} + // {{{ lastInsertID() + + /** + * Returns the autoincrement ID if supported or $id or fetches the current + * ID in a sequence called: $table.(empty($field) ? '' : '_'.$field) + * + * @param string $table name of the table into which a new row was inserted + * @param string $field name of the field into which a new row was inserted + * @return mixed MDB2 Error Object or id + * @access public + */ + function lastInsertID($table = null, $field = null) + { + $seq = $table.(empty($field) ? '' : '_'.$field); + $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq), true); + return $this->queryOne("SELECT $sequence_name.currval", 'integer'); + } + + // }}} // {{{ currId() /** @@ -925,8 +944,8 @@ */ function currId($seq_name) { - $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true); - return $this->queryOne("SELECT $sequence_name.currval FROM DUAL"); + $sequence_name = $db->getSequenceName($seq_name); + return $this->queryOne("SELECT last_number FROM user_sequences WHERE sequence_name='$sequence_name", 'integer'); } }

« previous php.pear.cvs (#42680) next »