Re: What do you think which mode will be standard for PEAR Error handling in PHP5?

From: Date: Wed, 03 Dec 2003 15:51:05 +0000
Subject: Re: What do you think which mode will be standard for PEAR Error handling in PHP5?
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9275@lists.php.net to get a copy of this message
On Wednesday 03 December 2003 9:14, Michael Wallner wrote: > ...so catch() replaces PEAR::isError() > Yeah, I get that part. But it seems to me that PEAR needs some kind of isError callback for all the code that is using PEAR modules. Within the modules it would all be try...catch, but take the following code as an example. While I don't think that we would need to worry about backward compatibility for the pear modules themselves, it might be a good idea to think about the users (though I could be biased on that one). <?php // include PEAR::DB require_once 'DB.php'; // connect to the database $myDb = DB::connect('pgsql://user:pass@host/database'); // check that the connection is valid if (DB::isError($myDb)) { die ($myDb->getMessage()); } // query the database $sql = "SELECT * FROM table WHERE col = 'value'"; $result = $myDb->query($sql); // check to see if the query worked if (DB::isError($result)) { // query failed $error = $result->getMessage(); } else { // process query results } ?> -Jackson

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