PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2 » Bug #3581

oci8::numRows() and _fillBuffer() issues

Details

Submitted2005-02-24 15:46 UTC
Fromsbeam at onsetcorps dot net
Assignedlsmith
StatusClosed
PackageMDB2
PHP Version5.0.3
OSlinux
Roadmaps(Not assigned)

Comments

[2005-02-24 15:46 UTC] sbeam at onsetcorps dot net

Description:
------------
numRows() was only returning the value of $res->buffer_rownum - but if an offset exists, this number would be less the offset. Attached patch adds $res->limits[count] to the result to always get the total # of rows that the query returned.

Also, _fillBuffer() was not counting rows at all if the buffer_rownum got above the limit. Changes to _fillBuffer() to increment buffer_rownum for every OCIFetchInto(), but only add the row to $buffer if it is between offset and limit.

And the other change to set $row = false prevents fetchRow() from getting an extra "blank" row at the end of each limited result set.

Reproduce code:
---------------
@@ -934,14 +937,15 @@
return false;
}

- $row = true;
+ $row = false;
while ((is_null($rownum) || $this->buffer_rownum < $rownum)
- && (!isset($this->limits) || $this->buffer_rownum < $this->limits['
limit'])
&& ($row = @OCIFetchInto($this->result, $buffer, OCI_RETURN_NULLS))
) {
++$this->buffer_rownum;
+ if (!isset($this->limits) || $this->buffer_rownum <= $this->limits[
'limit']) {
$this->buffer[$this->buffer_rownum] = $buffer;
}
+ }

if (!$row) {
++$this->buffer_rownum;
@@ -1052,7 +1056,7 @@
'seek: resultset has already been freed');
}
$this->_fillBuffer();
- return $this->buffer_rownum;
+ return ($this->buffer_rownum) + $this->limits['count'];
}

// }}}

[2005-02-24 21:38 UTC] smith at backendmedia dot com

Could you check out current CVS alot of things have changed there over the last 9 months.

[2005-06-03 07:50 UTC] smith at backendmedia dot com

any chances to get this tested?

[2005-10-10 15:16 UTC] sbeam at onsetcorps dot net

no, the production system was based on the MDB2 release with the below patch. Unfortunately I don't have access to a proper testing server with Oracle or time to set one up so I have not been able to test it with the CVS version.