Re: Bugs in PEAR::DB
| From: | Tomas V.V.Cox | Date: | Thu, 12 Jul 2001 22:34:08 +0000 |
| Subject: | Re: Bugs in PEAR::DB | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-690@lists.php.net to get a copy of this message | ||
Paul DuBois wrote:
>
> At 12:47 AM +0300 7/13/01, yavo wrote:
> >I find it hard to use numRows after using getAll/getAssoc can somthing be
> >done about it, the db object only allows numRows if you pass it the result
> >object. for exmaple this
> >
> > $sql = "SELECT * FROM SOMETABLE";
> > $res = $db->query($sql);
> > $data = $db->getAll($sql);
> > $rows = $res->numRows();
> >
> >would work but it's not the most elegant way to do it :) . Any ideas. Maybe
> >have a getLastResult method could help.
>
> If PEAR::DB acts like other DB-access interfaces, this is because the
> number of rows is available only while the result set object is active,
> and for these shortcut methods the object has already been disposed of
> by the time the method returns.
>
> A typical workaround for other interfaces is to get the size of the
> result set from the size of the data structure returned by the method.
> Can you do that?
>
Yeah.
$data = $db->getAll($sql);
$numrows = count($data);
Tomas V.V.Cox