代码错误会话DB [英] Codeigniter error session DB

查看:109
本文介绍了代码错误会话DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级Codeigniter到版本3.0之后,我尝试调用任何控制器后得到错误数据库:

 错误号码:1064 

您的SQL语法中有错误;检查对应于您的MySQL服务器版本的手册,在第2行附近使用'WHERE`id` ='d1d384b0ceed0bd72fa210337acc666aab1a04e5''正确的语法

SELECT`data` WHERE`id` ='d1d384b0ceed0bd72fa210337acc666aab1a04e5'

文件名:libraries / Session / drivers / Session_database_driver.php

重载页面,我再次与其他生成的哈希会话。如何修复?



config.php 我设置会话存储: $ config [ 'sess_driver'] ='数据库';



我看着文件哪里是一个错误(行138):

  public function read($ session_id)
{
if($ this-> _get_lock($ session_id)!== FALSE )
{
//需要write()来检测session_regenerate_id()调用
$ this-> _session_id = $ session_id;

$ this-> _db
- > select('data')
- > from($ this-> _config ['save_path'])
- > where('id',$ session_id);

if($ this-> _config ['match_ip'])
{
$ this-> _db-> where('ip_address',$ _SERVER [' REMOTE_ADDR']);
}

if(($ result = $ this-> _db-> get() - > row())=== NULL)// Line 138
{
$ this-> _fingerprint = md5('');
return'';
}

$ this-> _fingerprint = md5(rtrim($ result-> data));
$ this-> _row_exists = TRUE;
return $ result-> data;
}

$ this-> _fingerprint = md5('');
return'';
}


解决方案

它花了我一会儿找到解决方案。表面上,指令告诉你只是加载会话驱动程序,一切都很酷,但如果你看下来在CodeIgniter文档的数据库驱动程序部分,你会发现,你需要配置$ config ['sess_save_path']变量在你的config.php文件。例如:

  $ config ['sess_save_path'] ='ci_sessions'
/ pre>

http:/ /www.codeigniter.com/userguide3/libraries/sessions.html#initializing-a-session



当然,您必须设置ci_sessions表格在你的数据库中,但是这解决了我缺少的表名。


After upgrade Codeigniter to version 3.0 I get error DB after trying call any controller:

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `id` = 'd1d384b0ceed0bd72fa210337acc666aab1a04e5'' at line 2

SELECT `data` WHERE `id` = 'd1d384b0ceed0bd72fa210337acc666aab1a04e5'

Filename: libraries/Session/drivers/Session_database_driver.php

When I reload page, I get that again with a other generated hash session. How to fix?

In config.php I set session store: $config['sess_driver'] = 'database';

I looked at file where is a error(line 138):

public function read($session_id)
    {
        if ($this->_get_lock($session_id) !== FALSE)
        {
            // Needed by write() to detect session_regenerate_id() calls
            $this->_session_id = $session_id;

            $this->_db
                ->select('data')
                ->from($this->_config['save_path'])
                ->where('id', $session_id);

            if ($this->_config['match_ip'])
            {
                $this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
            }

            if (($result = $this->_db->get()->row()) === NULL) // Line 138
            {
                $this->_fingerprint = md5('');
                return '';
            }

            $this->_fingerprint = md5(rtrim($result->data));
            $this->_row_exists = TRUE;
            return $result->data;
        }

        $this->_fingerprint = md5('');
        return '';
    }

解决方案

I had this same problem and it took me a while to find the solution. On the surface, the instructions tell you to just load the session driver and everything is cool, but if you look down in the Database Driver section of the CodeIgniter documentation, you find that you need to configure the $config[‘sess_save_path’] variable in your config.php file. For example:

 $config[‘sess_save_path’] = ‘ci_sessions’

http://www.codeigniter.com/userguide3/libraries/sessions.html#initializing-a-session

Of course, you have to have the ci_sessions table set up in your database as well, but this solved the missing table name for me.

这篇关于代码错误会话DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆