Php 对行进行计数并验证Codeigniter仅存在1个

Php 对行进行计数并验证Codeigniter仅存在1个,php,codeigniter,Php,Codeigniter,我有: 但我得到了一个错误: function check_if_loggedin(){ #get user session id from db. $sess = $this->session->userdata('session_id'); #set numerical value of successfully logged in equal 1 $loggedInSetSuccess = 1; #compare sess

我有:

但我得到了一个错误:

function check_if_loggedin(){
    #get user session id from db.
        $sess = $this->session->userdata('session_id');
    #set numerical value of successfully logged in equal 1
        $loggedInSetSuccess = 1;
    #compare session id to match in db (can only have only 1 match)
        $sessionsDbCompare = $this->db->get_where('Client',array('session_id'=>$sess,'loggedIn'=>$loggedInSetSuccess));

    if($this->db->num_rows($sessionsDbCompare) == 1) {
    # User has valid session(valid sessID+loggedIn=0, show welcome
        #show account settings with primary nav
            $this->load->view('v/supernavigationloggedin.php');
            $this->load->view('v/primarynavigation.php');    
    }
    else{
      # user doesnt have both a valid session and loggedIn is set to 0, show login form
            #show login form with primary nav
            $this->load->view('v/supernavigationnotloggedin.php');
            $this->load->view('v/primarynavigation.php');   
    }  
}
在以下行:

Fatal error: Call to undefined method CI_DB_mysql_driver::num_rows()
我验证了数据库库已加载到autoload.php中,并且活动记录已明确打开


我做错了什么?

将该行更改为:

if($this->db->num_rows($sessionsDbCompare) == 1) {

将该行更改为:

if($this->db->num_rows($sessionsDbCompare) == 1) {

好建议!谢谢蒂姆!好建议!谢谢蒂姆!