cvs: pear /DBA DBA_Table.php /DBA/tests test_relational.php
| From: | Brent Cook | Date: | Thu, 11 Jul 2002 03:51:48 +0000 |
| Subject: | cvs: pear /DBA DBA_Table.php /DBA/tests test_relational.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5023@lists.php.net to get a copy of this message | ||
busterb Wed Jul 10 23:51:48 2002 EDT
Modified files:
/pear/DBA DBA_Table.php
/pear/DBA/tests test_relational.php
Log:
Fixed failure on insert when no primary key is specified in the
table schema
Index: pear/DBA/DBA_Table.php
diff -u pear/DBA/DBA_Table.php:1.36 pear/DBA/DBA_Table.php:1.37
--- pear/DBA/DBA_Table.php:1.36 Wed Jul 10 13:57:30 2002
+++ pear/DBA/DBA_Table.php Wed Jul 10 23:51:48 2002
@@ -18,7 +18,7 @@
// | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA|
// +----------------------------------------------------------------------+
//
-// $Id: DBA_Table.php,v 1.36 2002/07/10 17:57:30 busterb Exp $
+// $Id: DBA_Table.php,v 1.37 2002/07/11 03:51:48 busterb Exp $
//
require_once 'PEAR.php';
require_once 'DB/DBA/DBA.php';
@@ -78,7 +78,7 @@
* @var int
* @access private
*/
- var $_maxKey=0;
+ var $_maxKey=null;
/**
* Field name to use as a primary key. Null indicates that there is no
@@ -167,7 +167,7 @@
$schema = $this->_packSchema($this->_schema);
$this->_dba->replace(DBA_SCHEMA_KEY, $schema);
}
- unset($this->_maxKey);
+ $this->_maxKey = null;
return $this->_dba->close();
}
@@ -301,11 +301,11 @@
{
$maxKey = 0;
$key = $this->_dba->firstkey();
- while ($key) {
- $key = $this->_dba->nextkey($key);
+ while ($key !== false) {
if (is_numeric ($key) && ($key > $maxKey)) {
$maxKey = $key;
}
+ $key = $this->_dba->nextkey($key);
}
return $maxKey;
}
@@ -319,7 +319,7 @@
function _getUniqueKey()
{
// find the maxKey if necessary
- if (!isset ($this->_maxKey)) {
+ if (is_null($this->_maxKey)) {
$this->_maxKey = $this->_findMaxKey();
}
@@ -630,7 +630,7 @@
}
// if this field is the primary key, set $primaryKey
- if ($fieldMeta['primarykey']) {
+ if (isset($fieldMeta['primarykey'])) {
$primaryKey = $c_value;
}
@@ -676,7 +676,7 @@
return $packedRow;
}
- if ($this->_primaryKey) {
+ if (!isset($this->_primaryKey)) {
if (!is_null($primaryKey)) {
$key = $primaryKey;
} else {
Index: pear/DBA/tests/test_relational.php
diff -u pear/DBA/tests/test_relational.php:1.17 pear/DBA/tests/test_relational.php:1.18
--- pear/DBA/tests/test_relational.php:1.17 Sun Jul 7 13:15:16 2002
+++ pear/DBA/tests/test_relational.php Wed Jul 10 23:51:48 2002
@@ -20,7 +20,7 @@
// | Author: Brent Cook <busterb@mail.utexas.edu> |
// +----------------------------------------------------------------------+
//
-// $Id: test_relational.php,v 1.17 2002/07/07 17:15:16 busterb Exp $
+// $Id: test_relational.php,v 1.18 2002/07/11 03:51:48 busterb Exp $
//
// test functionality of the dba table layer
@@ -49,6 +49,8 @@
if (PEAR::isError($result)) {
echo $result->getMessage()."\n";
}
+ // exercise sequences (autoincrement)
+ $db->close();
}
}
}