RE: [PHP-PEAR] The PEAR $db->fetchRow Blues (ref: DB_mysql...
[email protected] (Robert Kelly)
| Newsgroups | php.pear |
|---|---|
| Message-ID | <[email protected]> |
WRT: Examples: Chuck, Whoever: post a definitive sample of code, I'll document and donate to the cause (and to the pear.php.net site!!). I'm in the process of getting our group of coders all on the same page/standard. -Bob -----Original Message----- From: Chuck Hagenbuch [mailto:[email protected]] Sent: Thursday, February 15, 2001 8:06 AM To: [email protected] Subject: Re: [PHP-PEAR] The PEAR $db->fetchRow Blues (ref: DB_mysql... Quoting Robert Kelly <[email protected]>: > 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, <[email protected]> "My intuitive grasp of math often leads me astray." -Me -- PHP Extension and Add-on Repository (PEAR) mailing list. Documentation can be found at http://pear.php.net/doc/pear.html To unsubscribe, e-mail: [email protected] from the mail address you subscribed with.