致命错误:在字符串上调用成员函数query()

I am getting a fatal error, I tried to find a solution in stackoverflow and other forum but I can't seem to find it.

Error looks like:

Fatal error: Call to a member function query() on string in /home/......./check.php on line 19

class M_login extends CI_Model{
    public function num_of_students($name,$adress){     
        $sql="select * from tbl_admin where name='$name' and address='$address'";       
        $query=$this->db->query($sql);      
        return $query->num_rows();
    }
 public function num_of_students($name,$adress){     
    $sql="select * from tbl_admin where name='$name' and address='$address'";       
    $query=$this->db->query($sql)->get();      
    return $query->num_rows();
}

I hope this may help you...Thanks!