cvs: pear(MDB_1) /MDB/MDB Common.php
| From: | Lukas Smith | Date: | Tue, 09 Dec 2003 15:26:45 +0000 |
| Subject: | cvs: pear(MDB_1) /MDB/MDB Common.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-14726@lists.php.net to get a copy of this message | ||
lsmith Tue Dec 9 10:26:45 2003 EDT
Modified files: (Branch: MDB_1)
/pear/MDB/MDB Common.php
Log:
performance tweak to MDB_Common::fetchInto() and (query|get)(One|Row)
Index: pear/MDB/MDB/Common.php
diff -u pear/MDB/MDB/Common.php:1.114.4.6 pear/MDB/MDB/Common.php:1.114.4.7
--- pear/MDB/MDB/Common.php:1.114.4.6 Tue Nov 4 17:14:25 2003
+++ pear/MDB/MDB/Common.php Tue Dec 9 10:26:45 2003
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.114.4.6 2003/11/04 22:14:25 lsmith Exp $
+// $Id: Common.php,v 1.114.4.7 2003/12/09 15:26:45 lsmith Exp $
/**
* @package MDB
@@ -3600,9 +3600,6 @@
} else {
$this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result],
$row);
}
- if ($rownum + 1 > $this->numRows($result)) {
- return(NULL);
- }
$columns = $this->numCols($result);
if (MDB::isError($columns)) {
return($columns);
@@ -3687,15 +3684,12 @@
{
$fetchmode = is_numeric($colnum) ? MDB_FETCHMODE_ORDERED : MDB_FETCHMODE_ASSOC;
$column = array();
- $rownum = 0;
$row = $this->fetchInto($result, $fetchmode, $rownum);
if (is_array($row)) {
if (isset($row[$colnum])) {
$column[] = $row[$colnum];
- ++$rownum;
- while (is_array($row = $this->fetchInto($result, $fetchmode, $rownum))) {
+ while (is_array($row = $this->fetchInto($result, $fetchmode))) {
$column[] = $row[$colnum];
- ++$rownum;
}
} else {
$this->freeResult($result);
@@ -3744,8 +3738,7 @@
}
}
$all = array();
- $rownum = 0;
- while (is_array($row = $this->fetchInto($result, $fetchmode, $rownum))) {
+ while (is_array($row = $this->fetchInto($result, $fetchmode))) {
if ($rekey) {
if ($fetchmode & MDB_FETCHMODE_ASSOC) {
$key = reset($row);
@@ -3770,7 +3763,6 @@
$all[] = $row;
}
}
- ++$rownum;
}
if (!$this->options['autofree']) {
$this->freeResult($result);
@@ -3802,6 +3794,7 @@
if ($type != NULL) {
$type = array($type);
}
+ $this->setSelectedRowRange(0, 1);
$result = $this->query($query, $type);
if (MDB::isError($result)) {
return($result);
@@ -3828,6 +3821,7 @@
*/
function queryRow($query, $types = NULL, $fetchmode = MDB_FETCHMODE_DEFAULT)
{
+ $this->setSelectedRowRange(0, 1);
$result = $this->query($query, $types);
if (MDB::isError($result)) {
return($result);
@@ -3921,6 +3915,7 @@
$type = array($type);
}
settype($params, 'array');
+ $this->setSelectedRowRange(0, 1);
if (count($params) > 0) {
$prepared_query = $this->prepareQuery($query);
if (MDB::isError($prepared_query)) {
@@ -3972,6 +3967,7 @@
function getRow($query, $types = NULL, $params = array(), $param_types = NULL, $fetchmode =
MDB_FETCHMODE_DEFAULT)
{
settype($params, 'array');
+ $this->setSelectedRowRange(0, 1);
if (count($params) > 0) {
$prepared_query = $this->prepareQuery($query);
if (MDB::isError($prepared_query)) {