PEAR is archived and read-only

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

Home » Database » DB » Bug #5762

Empty getRow() result causes ocifreestatemet() error

Details

Submitted2005-10-24 10:04 UTC
Fromroehr at zilleon dot com
Assignedaharvey
StatusClosed
PackageDB
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-10-24 10:04 UTC] roehr at zilleon dot com

Description:
------------
Hi,

when running a query with getRow() that yields no results an error occurs with the OCI8 function ocifreestatement(). See below.

Thanks and best regards, Torsten Roehr

Test script:
---------------
$result = $db->getRow('SELECT * FROM table WHERE 1 = 0');

Expected result:
----------------
No error.

Actual result:
--------------
ocifreestatement(): supplied argument is not a valid OCI8-Statement resource, File: ...\PEAR\DB\oci8.php, Line: 418

Change line 418 from:
return @OCIFreeStatement($result);

to:
return ($result) ? OCIFreeStatement($result) : false;

[2005-11-28 12:39 UTC] roehr at zilleon dot com

The same applies to mysql.php
line 422 is: return @mysql_free_result($result);
should be: return ($result) ? mysql_free_result($result) : false;

Maybe other drivers are affected as well.

[2005-12-11 16:14 UTC] roehr at zilleon dot com

IMHO silencing errors is not the best way because PHP will still trigger an error and it will end up on my error stack. This is what I want to avoid.

[2007-01-11 12:43 UTC] roehr at zilleon dot com

I've upgraded to MDB2 meanwhile but it still wouldn't hurt to change:
return @OCIFreeStatement($result);
to:
return ($result) ? OCIFreeStatement($result) : false;

I had used PHP 4.3.10 and Oracle 9i. HTH.

Regards, Torsten