Re: Suggestion for fetchInto

From: Date: Sat, 21 Apr 2001 14:31:28 +0000
Subject: Re: Suggestion for fetchInto
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-285@lists.php.net to get a copy of this message
"Tomas V.V.Cox" wrote: > > Hi, Hi Tomas, > What do you think about setting the DB_OK constant to true o 1? It could > improve usability for some functions for ex: fetchInto(). > > Now you need to do: > > while (DB_OK === $res->fetchInto($row)) { > ... > } > > With the new value, people could simply use: > > while ($res->fetchInto($row)) { > ... > } > The approach to improve the fetch row user usability could be this: - DB_extensions always returns DB_errors on errors as they actually do, so if you set up a default PEAR error hlandler, errors could be catched by it. - Change DB_result::fetchInto to only returns "null" or "array". If it get an error from the extention, can use trigger_error (as used in PEAR::setErrorHandling) to notice it but always returns "null" in this case. - The DB_OK constant value should be changed from "0" to "1", so don't disturbs loops like while. I've made a little untested patch to represent this. Regards, Tomas V.V.Cox

« previous php.pear.dev (#285) next »