doudan5136 2016-04-03 11:06
浏览 109
已采纳

Codeigniter中的数据库错误1146

I am using Codeigniter framework to build a website. I am receiving this error:

Error Number: 1146
Table 'users.ci_sessions' doesn't exist

SELECT `data` FROM `ci_sessions` WHERE `id` = '5e47bcb40c2954bd7329ff3fbcf253007a0563cc'

Filename: libraries/Session/drivers/Session_database_driver.php
Line Number: 166

Here is how session is defined: In config.php:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_table_name'] = 'ci_sessions';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_driver'] = 'database';       // changed from file
$config['sess_save_path'] = 'ci_sessions'; // table name
//$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;
$config['sess_use_database'] = TRUE;

In autoload.php:

$autoload['libraries'] = array('database','session');

I have read https://ellislab.com/codeigniter/user-guide/libraries/sessions.html and followed all steps to properly access the session. Any suggestion on how to fix above error?

  • 写回答

3条回答 默认 最新

  • douji9184 2016-04-03 14:14
    关注

    Actually you are mixing up both session drivers i.e database and file, so if you would like to use file driver read here the official documentation: http://www.codeigniter.com/userguide3/libraries/sessions.html#files-driver

    And if you want to use database driver: http://www.codeigniter.com/userguide3/libraries/sessions.html#database-driver

    Also i had encounter an strange bug in auto loading libraries.

    Please add session driver before database driver in autoload array as:

    $autoload['libraries'] = array('session','database');

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀