0

我有:

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()

在以下行:

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

我验证了数据库库已加载到 autoload.php 中,并且活动记录肯定已打开。

我在这里做错了什么?

4

1 回答 1

3

将该行更改为:

if($sessionsDbCompare->num_rows() == 1) {
于 2012-11-09T03:46:09.157 回答