cvs: pear /MDB2 MDB2.php
| From: | Lukas Smith | Date: | Thu, 29 Apr 2004 20:19:10 +0000 |
| Subject: | cvs: pear /MDB2 MDB2.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-18977@lists.php.net to get a copy of this message | ||
lsmith Thu Apr 29 16:19:10 2004 EDT
Modified files:
/pear/MDB2 MDB2.php
Log:
- affectedRows() now ensures that the last query was a manipulation query
- allowing limits of 0 in setLimit()
- setParamsArray() can now handle non ordered arrays
- performance tweak in fetchCol()
http://cvs.php.net/diff.php/pear/MDB2/MDB2.php?r1=1.25&r2=1.26&ty=u
Index: pear/MDB2/MDB2.php
diff -u pear/MDB2/MDB2.php:1.25 pear/MDB2/MDB2.php:1.26
--- pear/MDB2/MDB2.php:1.25 Sun Apr 25 06:04:26 2004
+++ pear/MDB2/MDB2.php Thu Apr 29 16:19:09 2004
@@ -43,7 +43,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
//
-// $Id: MDB2.php,v 1.25 2004/04/25 10:04:26 lsmith Exp $
+// $Id: MDB2.php,v 1.26 2004/04/29 20:19:09 lsmith Exp $
//
/**
@@ -1621,7 +1621,7 @@
'setLimit: limit is not supported by this driver');
}
$limit = (int)$limit;
- if ($limit < 1) {
+ if ($limit < 0) {
return $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
'setLimit: it was not specified a valid selected range row limit');
}
@@ -1948,11 +1948,13 @@
*/
function setParamArray($prepared_query, $params)
{
- for ($i = 0, $j = count($params); $i < $j; ++$i) {
- $success = $this->setParam($prepared_query, $i + 1, $params[$i]);
+ $i = 0;
+ foreach ($params as $param) {
+ $success = $this->setParam($prepared_query, $i + 1, $param);
if (MDB2::isError($success)) {
return $success;
}
+ ++$i;
}
return MDB2_OK;
}
@@ -2109,9 +2111,14 @@
return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'affectedRows: method not implemented');
}
- if ($this->affected_rows == -1) {
- return $this->raiseError(MDB2_ERROR_NEED_MORE_DATA);
+ if (MDB2::isManip($this->last_query)) {
+ if ($this->affected_rows == -1) {
+ return $this->raiseError(MDB2_ERROR_NEED_MORE_DATA);
+ }
+ } else {
+ $affected_rows = 0;
}
+
return $this->affected_rows;
}
@@ -2645,13 +2652,15 @@
{
$column = array();
$fetchmode = is_numeric($colnum) ? MDB2_FETCHMODE_ORDERED : MDB2_FETCHMODE_ASSOC;
- while (is_array($row = $this->fetchRow($fetchmode))) {
+ $row = $this->fetchRow($fetchmode);
+ if (is_array($row)) {
if (!array_key_exists($colnum, $row)) {
- return($this->mdb->raiseError(MDB2_ERROR_TRUNCATED));
+ return($this->raiseError(MDB2_ERROR_TRUNCATED));
}
- $column[] = $row[$colnum];
+ do {
+ $column[] = $row[$colnum];
+ } while (is_array($row = $this->fetchRow($fetchmode)));
}
-
if (MDB2::isError($row)) {
return $row;
}