db inside a class

From: Date: Fri, 28 Mar 2003 11:08:08 +0000
Subject: db inside a class
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4491@lists.php.net to get a copy of this message
I'm trying to use the pear db insade a class of my own, I know that this have been up on the list before(did a search) but I could't get the help need from the privous aswers so here I go: I have a class: class Sample extends Something{ var $db_user; var $db_pass; var $db_host; var $db_name; var $db_engine; function Sample0() { ...sets the class variables... } function Sample5($recived_db_host, $recived_db_user, $recived_db_pass, uses the varibles recived as arguments instead... } function query($recived_db_query, $recived_fetch_metod , $recived_fetch_mode) { $dsn = $this->db_engine.'://'.$this->db_user.':'.$this->db_pass.'@'.$this-
db_host.'/' .$this->db_name;
$db = DB::connect($dsn, true); if (DB::isError($db)) { die($db->getMessage()); } $result = $db->query("SELECT * FROM Users_DB"); var_dump($result); if(DB::IsError($result)) { die($result->getMessage()); }
LINE 59 $row = $result->$recived_fetch_metod($recived_fetch_mode);
$result->free(); $db->disconnect(); } } i get: Call to a member function on a non-object in ... line 59; the var_dump($result); results in NULL, if a do a dump on $db then I get a object so I guess thats is ok that far, and then I thought that the query is the thing that fails but it's a simple "SELECT * FROM user" on the mysql db, does anyone have any idéas? .p

« previous php.pear.general (#4491) next »