cvs: pear /MDB2/MDB2/Driver oci8.php
| From: | Lukas Smith | Date: | Thu, 08 Jun 2006 17:51:36 +0000 |
| Subject: | cvs: pear /MDB2/MDB2/Driver oci8.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-40569@lists.php.net to get a copy of this message | ||
lsmith Thu Jun 8 17:51:36 2006 UTC
Modified files:
/pear/MDB2/MDB2/Driver oci8.php
Log:
- pass limit and offset to the result object constructor in _execute() for read statements
- optmized limit queries without offset
- make sure no additional fields are added due to using limit/offset
http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/oci8.php?r1=1.150&r2=1.151&diff_format=u
Index: pear/MDB2/MDB2/Driver/oci8.php
diff -u pear/MDB2/MDB2/Driver/oci8.php:1.150 pear/MDB2/MDB2/Driver/oci8.php:1.151
--- pear/MDB2/MDB2/Driver/oci8.php:1.150 Wed May 31 18:05:09 2006
+++ pear/MDB2/MDB2/Driver/oci8.php Thu Jun 8 17:51:36 2006
@@ -43,7 +43,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
-// $Id: oci8.php,v 1.150 2006/05/31 18:05:09 lsmith Exp $
+// $Id: oci8.php,v 1.151 2006/06/08 17:51:36 lsmith Exp $
/**
* MDB2 OCI8 driver
@@ -500,9 +500,13 @@
}
if ($limit > 0) {
// taken from http://svn.ez.no/svn/ezcomponents/packages/Database
- $min = $offset + 1;
$max = $offset + $limit;
- $query = "SELECT * FROM (SELECT a.*, ROWNUM rn FROM ($query) a WHERE ROWNUM
<= $max) WHERE rn >= $min";
+ if ($offset > 0) {
+ $min = $offset + 1;
+ $query = "SELECT * FROM (SELECT a.*, ROWNUM mdb2rn FROM ($query) a WHERE
ROWNUM <= $max) WHERE mdb2rn >= $min";
+ } else {
+ $query = "SELECT a.* FROM ($query) a WHERE ROWNUM <= $max";
+ }
}
}
return $query;
@@ -889,7 +893,10 @@
}
$null = null;
return $null;
-
+ }
+ // remove additional column at the end
+ if ($this->offset > 0) {
+ array_pop($row);
}
if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) {
$this->db->_fixResultArrayValues($row, MDB2_PORTABILITY_RTRIM);
@@ -966,6 +973,9 @@
return $this->db->raiseError(null, null, null,
'numCols: Could not get column count');
}
+ if ($this->offset > 0) {
+ --$cols;
+ }
return $cols;
}
@@ -1078,6 +1088,10 @@
return $null;
}
$row = $this->buffer[$target_rownum];
+ // remove additional column at the end
+ if ($this->offset > 0) {
+ array_pop($row);
+ }
if ($fetchmode & MDB2_FETCHMODE_ASSOC) {
$column_names = $this->getColumnNames();
foreach ($column_names as $name => $i) {
@@ -1331,7 +1345,7 @@
}
$result =& $this->db->_wrapResult($this->statement, $this->result_types,
- $result_class, $result_wrap_class);
+ $result_class, $result_wrap_class, $this->limit, $this->offset);
return $result;
}