RE: [PEAR] MDB questions
| From: | Lukas Smith | Date: | Mon, 23 Dec 2002 23:36:17 +0000 |
| Subject: | RE: [PEAR] MDB questions | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3064@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Michael Raidel [mailto:raidel@i-one.at]
> Sent: Monday, December 23, 2002 8:50 PM
> To: pear-general@lists.php.net
> Subject: Re: [PEAR] MDB questions
>
> Hello to all,
>
> I had the same problem as Lorenzo Alberton with fetchRow on more than
> one result but a slightly different solution and would be interested
in
> your opinion.
>
> >5) I tried some queries with MDB, and all worked fine for one-row
> >results. On the other hand, while looping thru a multi-row result I
> >could only fetch the first row.
>
>
> The lines which cause the problem are:
> > if (!$this->options['autofree'] && $res != NULL) {
> > $this->freeResult($result); }
>
> I changed the first line to this:
> if (!$this->options['autofree'] && $res == NULL) {
> so that freeResult is only called, when the query returns no result.
IMO
> the !$this->options['autofree'] is there to prevent freeResult from
> being called a second time, when it is already done in fetchInto. (the
> same line in fetchOne, fetchCol and fetchAll also has to be changed)
>
> If this is true, the line
> > if ($this->options['autofree'] && $res != NULL) {
> would be no permanent solution.
Actually all fetch[one|col|row|all] methods on the methods that make use
if these methods (query[one|col|row|all] and get[one|col|row|all|assoc])
free the result sets. If autofree is enabled they don't as then
fetchInto will already have done that.
This means if you want to fetch several rows with multiple columns you
should use one of the [fetch|query|get]all methods (or getAssoc). If you
want to fetch several rows with just one column you should use
[fetch|query|get]col.
Regards,
Lukas