Home » Database » DB » Bug #5762
Empty getRow() result causes ocifreestatemet() error
Details
| Submitted | 2005-10-24 10:04 UTC |
|---|---|
| From | roehr at zilleon dot com |
| Assigned | aharvey |
| Status | Closed |
| Package | DB |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| 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