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

Bug #2664 DB::isError() returns FALSE when DB_Error object is passed
Submitted: 2004-11-01 17:14 UTC
From: peteallen at gmail dot com Assigned: danielc
Status: Bogus Package: DB
PHP Version: 5.0.2 OS: RHEL 3 / cPanel installed
Roadmaps: (Not assigned)    
Subscription  


 [2004-11-01 17:14 UTC] peteallen at gmail dot com
Description: ------------ The problem I'm having seems to be faily unique to my situation, but I have managed to find at least one other complaint of the same issue. This was reported as a previous bug which was never resolved. It can be viewed at: http://bugs.php.net/bug.php?id=13923 I am a newbie, so please forgive any errors I make. The problem I'm having is that when I pass a query with an intentional mistake in it, an error object is returned (this is expected). However, when I pass that error object to DB::isError(), it returns false. Reproduce code: --------------- <?php require_once 'DB.php'; require '/home/devel/db_info.php'; $dsn = "mysql://{$db_user}:{$db_pass}@{$db_server}/{$db_name}"; $connection = DB::connect($dsn); $connection->setErrorHandling(PEAR_ERROR_RETURN); if (DB::isError($connection)) die($connection ->getMessage( )); $result = $connection->query("SELECT * FROM nonexistant"); if (DB::isError($result)) die($result->getMessage( )); ?> Expected result: ---------------- I expect DB::isError($connection) to return TRUE, and therefore produce an error message, since $connection is an error object. Actual result: -------------- The actual result is that DB::isError($connection) returns false, preventing an error message from being printed.

Comments

 [2004-11-02 18:30 UTC] danielc
Your test script worked fine for me. Plus I've never had or heard of a problem with isError(). Sounds like you have a bug in your script.
 [2004-11-02 18:55 UTC] peteallen at gmail dot com
The script works fine on other systems. The code I am attempting to use was taken direclty out of O'Reilly books on PHP. The problem isn't with the code, though it very well could be a problem with the configuration of PHP or PEAR on my system; I can't rule that out. However, I have not been able to find anything on the internet which describes this problem or how to fix it, and no one with whom I have consulted has had any idea. Whatever the reason, isError() is not recognizing the fact that the object being passed to it is an error object. Every other aspect of PEAR::DB which I have tested has worked as expected.