cvs: php4 /pear DB.php
| From: | Thomas V.V.Cox | Date: | Thu, 01 Nov 2001 15:14:17 +0000 |
| Subject: | cvs: php4 /pear DB.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1231@lists.php.net to get a copy of this message | ||
cox Thu Nov 1 10:14:17 2001 EDT
Modified files:
/php4/pear DB.php
Log:
- Added row limit support for fetchInto and fetchRow
- Added getRowCounter method for DB_result to get the row number
you are fetching in limited queries
Index: php4/pear/DB.php
diff -u php4/pear/DB.php:1.76 php4/pear/DB.php:1.77
--- php4/pear/DB.php:1.76 Mon Oct 29 18:37:27 2001
+++ php4/pear/DB.php Thu Nov 1 10:14:17 2001
@@ -17,7 +17,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: DB.php,v 1.76 2001/10/29 23:37:27 fmk Exp $
+// $Id: DB.php,v 1.77 2001/11/01 15:14:17 cox Exp $
//
// Database independent query interface.
//
@@ -600,6 +600,7 @@
{
var $dbh;
var $result;
+ var $row_counter = null;
/**
* DB_result constructor.
@@ -629,6 +630,27 @@
$fetchmode = DB_FETCHMODE_ASSOC;
$return_object = true;
}
+ if ($this->dbh->limit_from !== null) {
+ if ($this->row_counter === null) {
+ $this->row_counter = $this->dbh->limit_from;
+ // For Interbase
+ if ($this->dbh->options['limit'] == false) {
+ $i = 0;
+ while ($i++ <= $this->dbh->limit_from) {
+ $this->dbh->fetchInto($this->result, $arr, $fetchmode);
+ }
+ }
+ }
+ if ($this->row_counter >= (
+ $this->dbh->limit_from + $this->dbh->limit_count))
+ {
+ return null;
+ }
+ if ($this->dbh->options['limit'] == 'emulate') {
+ $rownum = $this->row_counter;
+ }
+ $this->row_counter++;
+ }
$res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum);
if ($res !== DB_OK) {
return $res;
@@ -660,6 +682,27 @@
$fetchmode = DB_FETCHMODE_ASSOC;
$return_object = true;
}
+ if ($this->dbh->limit_from !== null) {
+ if ($this->row_counter === null) {
+ $this->row_counter = $this->dbh->limit_from;
+ // For Interbase
+ if ($this->dbh->options['limit'] == false) {
+ $i = 0;
+ while ($i++ <= $this->dbh->limit_from) {
+ $this->dbh->fetchInto($this->result, $arr, $fetchmode);
+ }
+ }
+ }
+ if ($this->row_counter >= (
+ $this->dbh->limit_from + $this->dbh->limit_count))
+ {
+ return null;
+ }
+ if ($this->dbh->options['limit'] == 'emulate') {
+ $rownum = $this->row_counter;
+ }
+ $this->row_counter++;
+ }
$res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum);
if (($res === DB_OK) && isset($return_object)) {
$class = $this->dbh->fetchmode_object_class;
@@ -715,6 +758,11 @@
function tableInfo($mode = null)
{
return $this->dbh->tableInfo($this->result, $mode);
+ }
+
+ function getRowCounter()
+ {
+ return $this->row_counter;
}
}