summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas V.V.Cox <cox@php.net>2001-11-01 15:14:17 +0000
committerTomas V.V.Cox <cox@php.net>2001-11-01 15:14:17 +0000
commitfa15d6069cd5f5cd4e60175af72efb9601708969 (patch)
treee72e83f25f0845ece9eb3d1e0fac0c350a16ce97
parent2830e45fe7398e9bac027c73ae0579a05e3a9d3a (diff)
downloadphp-git-fa15d6069cd5f5cd4e60175af72efb9601708969.tar.gz
- 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
-rw-r--r--pear/DB.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/pear/DB.php b/pear/DB.php
index 48ed0e7a91..feea467ff3 100644
--- a/pear/DB.php
+++ b/pear/DB.php
@@ -600,6 +600,7 @@ class DB_result
{
var $dbh;
var $result;
+ var $row_counter = null;
/**
* DB_result constructor.
@@ -629,6 +630,27 @@ class DB_result
$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 @@ class DB_result
$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;
@@ -716,6 +759,11 @@ class DB_result
{
return $this->dbh->tableInfo($this->result, $mode);
}
+
+ function getRowCounter()
+ {
+ return $this->row_counter;
+ }
}
class DB_row