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

From: Date: Fri, 20 Oct 2006 14:22:10 +0000
Subject: cvs: pear /MDB2 MDB2.php /MDB2/MDB2/Driver pgsql.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42679@lists.php.net to get a copy of this message
lsmith Fri Oct 20 14:22:10 2006 UTC Modified files: /pear/MDB2 MDB2.php /pear/MDB2/MDB2/Driver pgsql.php Log: - initial step to fix the incorrect use of currID() for lastInsertID() emulation (Bug #9107) http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2.php?r1=1.263&r2=1.264&diff_format=u Index: pear/MDB2/MDB2.php diff -u pear/MDB2/MDB2.php:1.263 pear/MDB2/MDB2.php:1.264 --- pear/MDB2/MDB2.php:1.263 Sat Oct 14 13:42:20 2006 +++ pear/MDB2/MDB2.php Fri Oct 20 14:22:10 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: MDB2.php,v 1.263 2006/10/14 13:42:20 lsmith Exp $ +// $Id: MDB2.php,v 1.264 2006/10/20 14:22:10 lsmith Exp $ // /** @@ -3098,8 +3098,8 @@ */ function lastInsertID($table = null, $field = null) { - $seq = $table.(empty($field) ? '' : '_'.$field); - return $this->currID($seq); + return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'method not implemented', __FUNCTION__); } // }}} http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/pgsql.php?r1=1.160&r2=1.161&diff_format=u Index: pear/MDB2/MDB2/Driver/pgsql.php diff -u pear/MDB2/MDB2/Driver/pgsql.php:1.160 pear/MDB2/MDB2/Driver/pgsql.php:1.161 --- pear/MDB2/MDB2/Driver/pgsql.php:1.160 Sat Oct 14 20:00:26 2006 +++ pear/MDB2/MDB2/Driver/pgsql.php Fri Oct 20 14:22:10 2006 @@ -43,7 +43,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.160 2006/10/14 20:00:26 quipo Exp $ +// $Id: pgsql.php,v 1.161 2006/10/20 14:22:10 lsmith Exp $ /** * MDB2 PostGreSQL driver @@ -974,6 +974,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 currval('$sequence_name')", 'integer'); + } + + // }}} // {{{ currID() /**

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