Re: Usage of BD.php inside a class
| From: | Tomas V.V.Cox | Date: | Fri, 13 Apr 2001 20:40:18 +0000 |
| Subject: | Re: Usage of BD.php inside a class | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-47@lists.php.net to get a copy of this message | ||
Luc Saint-Elie wrote:
>
> Dean
>
> I tried $this-db because if I call my database connection with $db
>
> require_once( 'DB.php' );
> Class MyClass {
>
> function MyFunctionInsideAClass(){
> [....]
> $db = DB::connect(
> "mysql://$dbuser:$dbpass@$dbhost/$dbname" );
> $sql = "select id from login where username =
> '$username' and password = '$password'";
> >> THIS IS LINE 140 $query = $db->query($sql);
> $result =$db->numRows($query);
> $db->disconnect();
> [....]
>
> I get : Fatal error: Call to undefined function: query() in backend.php on
> line 140
>
The code seems to be right. Perhaps 'DB::connect' returns a Error
object. Try:
if (DB::isError($db = DB::connect(..))) {
print_r($db);
exit;
}
Tomas V.V.Cox