Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.2

Bug #5762 Empty getRow() result causes ocifreestatemet() error
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)    
Subscription  


 [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;

Comments

 [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 14:07 UTC] lsmith
I am handling this like this in MDB2: function free() { $free = @mysql_free_result($this->result); if (!$free) { if (is_null($this->result)) { return MDB2_OK; } return $this->db->raiseError(); } $this->result = null; return MDB2_OK; }
 [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 08:33 UTC] aharvey (Adam Harvey)
I can't actually reproduce this. Torsten, if you're still experiencing this, can you let me know what versions of PHP and Oracle you're running, please?
 [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
 [2007-01-12 00:53 UTC] aharvey (Adam Harvey)
Thanks, Torsten. I agree that your proposed change wouldn't hurt anyway, so I'm going to do it regardless; I was just curious to see if I could replicate the issue locally for testing purposes. Thanks again.
 [2007-01-12 03:11 UTC] aharvey (Adam Harvey)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.