Re: [PHP-PEAR] The PEAR $db->fetchRow Blues (ref: DB_mysql...
[email protected] (Vinai Kopp)
| Newsgroups | php.pear |
|---|---|
| Message-ID | <[email protected]> |
I like to use
while( $row = $result->fetchRow(DB_FETCHMODE_ASSOC) ){
if( DB::isError( $row ) ){
handle_db_error( $row );
break;
}
At least for me it is the most flexible and most understandable way of
handling things.
isError returning true for NULL (which isn't an error) makes things
IMVHO more complicated for newbies to understand.
Let's change all the DB fetchRow Functions to return NULL on end of
results consistently instead.
Vinai
> Robert Kelly wrote:
>
> The PEAR FETCHROW BLUES
>
> 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 )
>
> I can see the simplicity of version one, the error checking in
> version 2 and I don't care which one should be used. However, all
> of the very little documentation out there uses version one, and if
> you're/we're going to grow PEAR, you may want to concern yourself with
>
> barriers to entry (learning curve) and first impressions. As
> it stands now, if someone downloads PEAR and runs the "newbie"
> demoResult
> script, it doesn't work.
>
> _I_ on the other hand, wants to use the error checking version,
> because
> I am prone to fall flat on my face :)
>
> Is there any way to edit the phpbuilder articles?
> -Bob Kelly
> [email protected]