I have the below code which, when run, returns this error:
PHP Fatal error: Call to a member function count() on a non-object in /classes/User.php on line 36
public function find($user = null) {
if($user) {
$field = (is_numeric($user)) ? 'id' : 'email';
$data = $this->_db->get('*', 'users', array($field, '=', $user));
if($data->count()) { // This is line 36, the $_db variable is an instance of the DB class
$this->_data = $data->first();
return true;
}
}
return false;
}
What am I missing that is making $data not refer to an object?