PEAR is archived and read-only

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

Home » Database » DB » Bug #101

fetchRow method in oci8 backend ignores options["optimize"] setting

Details

Submitted2003-10-14 16:19 UTC
Frommassimo dot ferrario at inforeti dot it
Assigneddanielc
StatusClosed
PackageDB
PHP Version4.3.2
OSlinux
Roadmaps(Not assigned)

Comments

[2003-10-14 16:19 UTC] massimo dot ferrario at inforeti dot it

Description:
------------
I found a bug (or is it a feature?) in the fetchRow method implementation of the DB_oci8 class.

While fetchInto method checks if $this->options['optimize'] is set to 'portability', and if it is converts all the field names to lower case, fetchRow does not.

So, after a fetchRow, the code that looks for $row['key'] finds it empty, as only $row['KEY'] is set.

I did not notice this problem before before I always used the DB::fetchRow method, and in the code ->dbh->fetchInto is called.

The patch is simple:

function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT)
{
if ($fetchmode == DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
$moredata = @OCIFetchInto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS);
} else {
$moredata = @OCIFetchInto($result, $row, OCI_RETURN_NULLS + OCI_RETURN_LOBS);
}
if (!$moredata) {
return NULL;
}
//patch begin
elseif ($this->options['optimize'] == 'portability')
$row = array_change_key_case($row, CASE_LOWER);
//patch else
return $row;
}

Please note that I am using // $Id: oci8.php,v 1.4 2002/07/02 16:39:16 mj Exp $ this version of the oci8 library

[2003-12-23 09:28 UTC] massimo dot ferrario at inforeti dot it

What do you mean with "version 1.9"?
I can only see 1.5.0 RC2 in the DB package information page (http://pear.php.net/package/DB).
Do you really want to remove the fetchRow method from the DB_result object and break nearly all the code around?