cvs: pear /MDB2/MDB2/Driver ibase.php
| From: | Lorenzo Alberton | Date: | Tue, 26 Oct 2004 10:16:29 +0000 |
| Subject: | cvs: pear /MDB2/MDB2/Driver ibase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-25238@lists.php.net to get a copy of this message | ||
quipo Tue Oct 26 06:16:29 2004 EDT
Modified files:
/pear/MDB2/MDB2/Driver ibase.php
Log:
fix nextID() and currID()
http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/ibase.php?r1=1.43&r2=1.44&ty=u
Index: pear/MDB2/MDB2/Driver/ibase.php
diff -u pear/MDB2/MDB2/Driver/ibase.php:1.43 pear/MDB2/MDB2/Driver/ibase.php:1.44
--- pear/MDB2/MDB2/Driver/ibase.php:1.43 Tue Oct 26 06:02:33 2004
+++ pear/MDB2/MDB2/Driver/ibase.php Tue Oct 26 06:16:26 2004
@@ -43,7 +43,7 @@
// | Author: Lorenzo Alberton <l.alberton@quipo.it> |
// +----------------------------------------------------------------------+
//
-// $Id: ibase.php,v 1.43 2004/10/26 10:02:33 quipo Exp $
+// $Id: ibase.php,v 1.44 2004/10/26 10:16:26 quipo Exp $
/**
* MDB2 FireBird/InterBase driver
@@ -484,10 +484,10 @@
*/
function nextID($seq_name, $ondemand = true)
{
- $sequence_name = $this->getSequenceName($seq_name);
+ $sequence_name = strtoupper($this->getSequenceName($seq_name));
$this->pushErrorHandling(PEAR_ERROR_RETURN);
$query = "SELECT GEN_ID($sequence_name, 1) as the_value FROM RDB\$DATABASE";
- $result = $this->queryOne($query);
+ $result = @$this->queryOne($query);
$this->popErrorHandling();
if (MDB2::isError($result)) {
if ($ondemand) {
@@ -501,7 +501,9 @@
'nextID: on demand sequence could not be created');
} else {
// First ID of a newly created sequence is 1
- return 1;
+ // return 1;
+ // BUT generators are not always reset, so return the actual value
+ return $this->currID($seq_name);
}
}
}
@@ -520,10 +522,9 @@
*/
function currID($seq_name)
{
- //$sequence_name = $this->getSequenceName($seq_name);
$sequence_name = strtoupper($this->getSequenceName($seq_name));
- $query = "SELECT RDB\$GENERATOR_ID FROM RDB\$GENERATORS WHERE
RDB\$GENERATOR_NAME='$sequence_name'";
- $value = $this->queryOne($query);
+ $query = "SELECT GEN_ID($sequence_name, 0) as the_value FROM RDB\$DATABASE";
+ $value = @$this->queryOne($query);
if (MDB2::isError($value)) {
return $this->raiseError(MDB2_ERROR, null, null,
'currID: Unable to select from ' . $seqname) ;