Re: Bugs in PEAR::DB

From: Date: Fri, 13 Jul 2001 00:16:28 +0000
Subject: Re: Bugs in PEAR::DB
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-696@lists.php.net to get a copy of this message
yavo@itena.com.cy (Yavo) wrote in news:20010712214728.49763.qmail@pb1.pair.com: > 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. Why don't you just do: $sql = "SELECT * FROM SOMETABLE"; $data = $db->getAll($sql); $rows = sizeof($data); ? Since all the results are returned by getAll, if no results are returned, you get an empty array. If 50 rows are returned, you should have 50 elements in $data. AFAIK, get* functions automatically free the result object, so they can't really pass back a result handle.

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