Re: Re: PHP exceptions (was: MDB2 simple test)

From: Date: Sat, 11 Nov 2006 21:51:45 +0000
Subject: Re: Re: PHP exceptions (was: MDB2 simple test)
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25773@lists.php.net to get a copy of this message
Lukas Kahwe Smith wrote:
make sure you check for error. $res =& $mdb2->query('SELECT * FROM articles'); if (PEAR::isError($res)) { die($res->getMessage().' - '.$res->getUserinfo()); } while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) alternatively you can set a global error handler. check out this article: http://www.php-mag.net/magphpde/magphpde_article/psecom,id,330,nodeid,21.html
That was an exceptionally (heh) difficult article to get through. To be fair, a good deal of the problem was due to the cramped formatting (and all of that code in the text is crying out for some highlighting). But i found the reasoning to be a bit convoluted. Not that i think it's bogus, mind. I just don't think it's the best way to approach this. I suppose, though, that there may be some advantage to the ideas suggested in the article when using PEAR_Error. I'll have to think about it some more. Personally, i've been trying to move my code to use proper exception handling. http://ca3.php.net/exceptions http://devzone.zend.com/node/view/id/666 brian

« previous php.pear.general (#25773) next »