RE: [PEAR] Pear db question
| From: | LIMBOURG Arnaud | Date: | Mon, 05 Aug 2002 12:26:09 +0000 |
| Subject: | RE: [PEAR] Pear db question | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-2056@lists.php.net to get a copy of this message | ||
Hello,
using the get* methods do all the allocating and freeing of resources.
In your example $rs will contain an array of data.
So, either you do a
$query = SELECT count(*) FROM TABLE
$db->getOne($query);
or
$rs = $db->query("SELECT * FROM table WHERE id='$id'");
//$rs is then a DB_result object
then
$numrows = $rs->numRows();
You can check for errors with
if (PEAR::isError($rs)) {
die($rs->getMessage());
}
Arnaud.
> I am having a little bit of a simple problem:
>
> $rs = $db->getRow("SELECT * FROM table WHERE id='$id'");
> $numrows = $rs->numRows();
>
> Won't work...how do I tell if a valid row has been retrieved or not?
> Wrap the getRow statement within an If statement?
>
> Sean Chambers
> Web Developer
> Vann Data Technology Centre
> Daytona Beach, FL
> (386) 238-1200 ext. 1205
> chamberss@vanndata.com
>
>