Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0b5

Bug #12958 error in lastInsertID method
Submitted: 2008-01-22 20:31 UTC
From: afz Assigned: quipo
Status: Closed Package: MDB2_Driver_ibase (version CVS)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2008-01-22 20:31 UTC] afz (Ali Fazelzadeh)
Description: ------------ hi, i test this method on Interbase 7.x and require this patch. thanks

Comments

 [2008-01-22 20:31 UTC] afz (Ali Fazelzadeh)
Index: ibase.php =================================================================== RCS file: /repository/pear/MDB2/MDB2/Driver/ibase.php,v retrieving revision 1.212 diff -u -r1.212 ibase.php --- ibase.php 22 Jan 2008 15:52:12 -0000 1.212 +++ ibase.php 22 Jan 2008 20:32:30 -0000 @@ -899,8 +899,7 @@ */ function lastInsertID($table = null, $field = null) { - $seq = $table.(empty($field) ? '' : '_'.$field); - return $this->currID($seq); + return $this->currID($table); } // }}}
 [2008-01-24 20:58 UTC] dufuz (Helgi Þormar Þorbjörnsson)
Your patch isn't required if you call $foobar->lastInsertID('tablename'); because the field name isn't appended unless you pass it along, or am I missing the point ? Are you perhaps passing both (for compatibility sakes) and ibase can't handle it ?
 [2008-01-25 05:46 UTC] afz (Ali Fazelzadeh)
another patch: (maybe better): Index: ibase.php =================================================================== RCS file: /repository/pear/MDB2/MDB2/Driver/Manager/ibase.php,v retrieving revision 1.108 diff -u -r1.108 ibase.php --- ibase.php 3 Dec 2007 20:59:15 -0000 1.108 +++ ibase.php 25 Jan 2008 05:53:59 -0000 @@ -138,6 +138,7 @@ return $db; } + $mix_name = $table . '_' . $name; if (is_null($start)) { $db->beginTransaction(); $query = 'SELECT MAX(' . $db->quoteIdentifier($name, true) . ') FROM ' . $db->quoteIdentifier($table, true); @@ -146,18 +147,18 @@ return $start; } ++$start; - $result = $db->manager->createSequence($table, $start); + $result = $db->manager->createSequence($mix_name, $start); $db->commit(); } else { - $result = $db->manager->createSequence($table, $start); + $result = $db->manager->createSequence($mix_name, $start); } if (PEAR::isError($result)) { return $db->raiseError(null, null, null, 'sequence for autoincrement PK could not be created', __FUNCTION__); } - $sequence_name = $db->getSequenceName($table); - $trigger_name = $db->quoteIdentifier($table . '_AUTOINCREMENT_PK', true); + $sequence_name = $db->getSequenceName($mix_name); + $trigger_name = $db->quoteIdentifier($mix_name . '_AUTOINCREMENT_PK', true); $table = $db->quoteIdentifier($table, true); $name = $db->quoteIdentifier($name, true); $trigger_sql = 'CREATE TRIGGER ' . $trigger_name . ' FOR ' . $table . '
 [2008-01-27 03:29 UTC] afz (Ali Fazelzadeh)
Interbase/Firebird support multi autoincrement filed, so for support thsi feature, we must use field name in trigger and sequence names.
 [2008-01-27 18:29 UTC] quipo (Lorenzo Alberton)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.