致命错误调用数字函数no.of行

public function email_check()
    {
        $this->form_validation->set_message('email_check', 'The %s '.$this->input->post('usr_email').' is already exist');
        $this->db->where('usr_email', $this->input->post('usr_email'));
        $query = $this->db->get('users');
        if ($query->num_rows()>0)
            return false;
        else
            return true;      


    }

( ! ) Fatal error: Call to a member function num_rows() on a non-object in C:\wamp\www\application\controllers\users.php on line 264

Call Stack

#   Time    Memory  Function    Location
1   0.0005  266584  {main}( )   ..\index.php:0
2   0.0015  324704  require_once( 'C:\wamp\www\\system\core\CodeIgniter.php' )  ..\index.php:202
3   0.0440  4030256 call_user_func_array:{C:\wamp\www/\system\core\CodeIgniter.php:359} ( ) ..\CodeIgniter.php:359
4   0.0440  4031120 Users->save_registration( ) ..\CodeIgniter.php:359
5   0.0440  4044000 CI_Form_validation->run( )  ..\users.php:302
6   0.0450  4056264 CI_Form_validation->_execute( ) ..\Form_validation.php:341
7   0.0450  4057600 Users->email_check( )   ..\Form_validation.php:593

If you want do validation for unique email address. Do the following

$this->form_validation->set_rules('email', 'email', 'required|is_unique[tablename.fieldname]');

I think you are doing wrong. try this.

$result = $this->db->where('usr_email', $this->input->post('usr_email'))
                   ->get('users')
                   ->num_rows();

if($result > 0)
{
     return false; // value you want true or false
}
else
{
     return true; // value you want true or false
}