Re: Pear Db layer

From: Date: Sat, 30 Sep 2000 17:26:37 +0000
Subject: Re: Pear Db layer
References: 1 2  Groups: php.pear 
Request: Send a blank email to php-pear+get-305@lists.php.net to get a copy of this message
Quoting Richard Heyes <php@heyes-computing.net>: > 1. When doing a query ( $dbh->query() ) it seems to always returns > something valid, either a result object or an error object. So the only > way I can see of testing whether the query was successful is something > like this: > > if(get_class($result = $dbh->query('SELECT * FROM users')) == > 'db_result'){ > // Success, do stuff. > }else{ > die('Something barfed... '); > } > > Is there a better way? Yes: if (DB::isError($result = $dbh->query($query))) { // error condition, handle it } else { anything that's conditional on success } > 2. There didn't appear to be a numRows() method or a affectedRows() > method. If this is just a case of it not having been gotten around to, > there's some code below that works. From the comments in the code, this are on the wishlist; I'll look at adding your code, but the issue may be simply how to implement this for dbs other than mysql... -chuck -- Charles Hagenbuch, <chuck@horde.org> -- ...and remember: elmo is _not_ an insertion toy.

« previous php.pear (#305) next »