Re: Suggestion for fetchInto
| From: | Tomas V.V.Cox | Date: | Sat, 21 Apr 2001 11:01:40 +0000 |
| Subject: | Re: Suggestion for fetchInto | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-283@lists.php.net to get a copy of this message | ||
Chuck Hagenbuch wrote:
>
> Quoting "Tomas V.V.Cox" <cox@idecnet.com>:
>
> > Now you need to do:
> >
> > while (DB_OK === $res->fetchInto($row)) {
> > ...
> > }
> >
> > With the new value, people could simply use:
> >
> > while ($res->fetchInto($row)) {
>
> That would fail miserably if an error was returned.
This wouldn't fail if you use it with PEAR::setErrorHandling(). IMHO we
don't have to expect that people check errors by hand on the fetch loop.
With PHPlib people simply do that for fetching rows:
while ($db->next_record()){
$name = $db->f('name');
...
}
Do you think that someone would change to Pear DB if he must to do that
(the absolute correct way I can think):
do {
$err = $res->fetchInto($row, DB_FETCHMODE_ASSOC);
if ($err === DB_OK) {
$name = $row['name'];
...
}
} while ($err === DB_OK);
if (DB::isError($err)) {
die ($err->getMessage());
}
?
Me at least not.
Tomas V.V.Cox