更新ci_session时数据库错误?我正在使用多个数据库?

时间:2016-07-14 05:48:34

标签: php codeigniter session multiple-databases

  

错误号码:1146

     

buz85ftp_buzoonga2.ci_sessions不存在

UPDATE `ci_sessions` SET `last_activity` = 1468474888, `user_data` = 'a:11:{s:9:\"user_data\";s:0:\"\";s:6:\"userid\";s:3:\"670\";s:5:\"phone\";s:10:\"9956451235\";s:7:\"emailid\";s:15:\"tester@test.com\";s:4:\"name\";s:6:\"Tester\";s:8:\"usertype\";s:1:\"1\";s:16:\"user_country_ref\";s:3:\"673\";s:12:\"user_country\";s:1:\"0\";s:9:\"time_zone\";s:12:\"Asia/Kolkata\";s:14:\"user_logged_in\";b:1;s:17:\"flash:new:success\";s:56:\"
  

消息被删除

     

\“;}'WHERE session_id ='f171da0c9be6fa5eb8d32905c8e1251b'

     

文件名:libraries / Session.php

     

行号:288

function sess_write()
    {
        // Are we saving custom data to the DB?  If not, all we do is update the cookie
        if ($this->sess_use_database === FALSE)
        {
            $this->_set_cookie();
            return;
        }

        // set the custom userdata, the session data we will set in a second
        $custom_userdata = $this->userdata;
        $cookie_userdata = array();

        // Before continuing, we need to determine if there is any custom data to deal with.
        // Let's determine this by removing the default indexes to see if there's anything left in the array
        // and set the session data while we're at it
        foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
        {
            unset($custom_userdata[$val]);
            $cookie_userdata[$val] = $this->userdata[$val];
        }

        // Did we find any custom data?  If not, we turn the empty array into a string
        // since there's no reason to serialize and store an empty array in the DB
        if (count($custom_userdata) === 0)
        {
            $custom_userdata = '';
        }
        else
        {
            // Serialize the custom data array so we can store it
            $custom_userdata = $this->_serialize($custom_userdata);
        }
        // Run the update query
        $this->CI->db->where('session_id', $this->userdata['session_id']);
        $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));

        // Write the cookie.  Notice that we manually pass the cookie data array to the
        // _set_cookie() function. Normally that function will store $this->userdata, but
        // in this case that array contains custom data, which we do not want in the cookie.
        $this->_set_cookie($cookie_userdata);
    }

2 个答案:

答案 0 :(得分:0)

创建一个名为ci_sessions的表,然后重试

答案 1 :(得分:0)

$ this-> CI-> load->数据库('databasename',TRUE);