Hi,
I have the following class:
In class DB I have:
public function get() in class DB, after processing, returns $this, the single instance of class DB, this is assigned to $data which is then used to invoke public function count(), a member function of class DB. I am getting the following error:
Fatal error: Call to a member function count() on a non-object.
I would be very grateful if someone can point out my mistake.
I have the following class:
Code:
class User
{ private $_db;
public function __construct($user = null)
{
$this->_db = DB::getInstance();
.......
}
public function find($user = null)
{ if($user)
{ $field = (is_numeric($user)) ? 'id' : 'username';
$data = $this->_db->get('users', array($field, '=', $user));
if($data->count())
{ .........
return true;
}
}
return false;
}
In class DB I have:
Code:
public static function getInstance()
{ if(!(self::$_instance)): self::$_instance = new self();
endif;
return self::$_instance;
}
public function get() in class DB, after processing, returns $this, the single instance of class DB, this is assigned to $data which is then used to invoke public function count(), a member function of class DB. I am getting the following error:
Fatal error: Call to a member function count() on a non-object.
I would be very grateful if someone can point out my mistake.