Re: The PEAR $db->fetchRow Blues (ref: DB_mysql...
| From: | Chuck Hagenbuch | Date: | Thu, 15 Feb 2001 15:06:02 +0000 |
| Subject: | Re: The PEAR $db->fetchRow Blues (ref: DB_mysql... | ||
| Groups: | php.pear | ||
| Request: | Send a blank email to php-pear+get-1354@lists.php.net to get a copy of this message | ||
Quoting Robert Kelly <rkelly@Insight.com>:
> current CVS version
> // no work
> while($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
> // because the fetchRow line return $this->raiseError
>
> // works
> while (! DB::isError ( $row = $result->fetchRow (DB_FETCHMODE_ASSOC)) ){
> // but makes the if $moredata==NULL redundant (? please confirm )
Yes, I changed things. In my defense, none of this was consistent between the
various db backends in the first place. Anyway.
One of my other changes was to make DB::isError() return true (ie, yes, this is
an error) when it is passed null. This lets you use the second loop and have it
terminate _both_ when an error occurs and when you reach the end of your
results. Otherwise, either of the above checks is prone to an infinite loop.
So: we want to standardize that fetchRow() should always return null when the
end of the result set is reached, that's fine - as long as the DB::isError()
change stays - and I will make this change for all backends. I just think it
should be consistent.
And if there are examples out there, we'll just have to correct them or put up
more authoritative, accurate ones.
-chuck
--
Charles Hagenbuch, <chuck@horde.org>
"My intuitive grasp of math often leads me astray." -Me