RE: [PEAR] numRows() trouble....
| From: | daniel dot garcia at assertio dot es | Date: | Fri, 30 May 2003 07:56:43 +0000 |
| Subject: | RE: [PEAR] numRows() trouble.... | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-5702@lists.php.net to get a copy of this message | ||
I had a problem getting the number of rows in a result set with an ODBC
DSN, because the odbc controller didn't support the method.
I did that:
$sql = "SELECT * FROM users WHERE swipe_id = '$clientid'";
$result = $db_obj->simpleQuery($sql);
if (DB::isError($result)) {
die($result->getMessage());
}
$result_num = $db_obj->query($sql);
$num = $result_num->numRows();
if (DB::isError($num)) {
$sql = "SELECT COUNT(*) FROM users WHERE swipe_id = '$clientid'";
$num = $db_obj->getOne($sql);
}
Regards,
Daniel
"Lukas Smith" <smith@backendmedia.com>
29/05/2003 18:30
Para: <a.bashir@tees.ac.uk>, <pear-general@lists.php.net>
cc:
Asunto: RE: [PEAR] numRows() trouble....
> From: a.bashir@tees.ac.uk [mailto:a.bashir@tees.ac.uk]
> Sent: Thursday, May 29, 2003 6:05 PM
>
> Being new to PHP and PEAR I may be missing something but I wanted to
> retrieve the number of rows from a query, in particular I wanted to
> check if only one row is being returned.
>
> I tried the following code:
>
> $sql = "SELECT * FROM users WHERE swipe_id = '$clientid'";
> $result = $db_obj->simpleQuery($sql);
> if (DB::isError($result)) {
> die($result->getMessage());
> }
> $result_num = $db_obj->query($sql);
> $num = $result_num->numRows();
>
> But I get:
>
> Fatal error: Call to a member function on a non-object in
> /usr/local/apache/htdocs/icon/prodigy/result_clientsearch.php on line
> 39
>
> line 39 : $result = $db_obj->simpleQuery($sql);
it just seems that $db_obj does not contain a PEAR DB object. Most
likely it contains an Error object.
Please do
print_r($db_obj);
or
if (DB::isError($db_obj)) {
die($db_obj->getMessage());
}
also please read up on PEAR error handling:
http://www.phpkitchen.com/staticpages/index.php?page=2003041204203962
http://php-mag.net/itr/online_artikel/psecom,id,330,nodeid,114.html
regards,
Lukas
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php