在Codeigniter 3.0中,致命错误:调用一个成员函数row(),在C:\mypath\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \Session_database_driver.php。

时间:2022-10-06 23:35:40

I try to setup session in database. but seem not work.

我尝试在数据库中设置会话。但似乎没有工作。

Database

数据库

CREATE TABLE IF NOT EXISTS `ci_sessions` (
    `id` varchar(40) NOT NULL,
    `ip_address` varchar(45) NOT NULL,
    `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
    `data` blob NOT NULL,
    PRIMARY KEY (id),
    KEY `ci_sessions_timestamp` (`timestamp`)
);

config.php

config。

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessions';

Source code

源代码

class Login extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
    }

    public function index(){
        echo "test";
    }
}

Error

错误

在Codeigniter 3.0中,致命错误:调用一个成员函数row(),在C:\mypath\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \Session_database_driver.php。

2 个解决方案

#1


1  

Change your application/config/config.php file setting to

改变你的应用程序/配置/配置。php文件设置

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessions';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';//its your table name name
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;

Read Session Preferences

读会话的偏好

Don't forget it to load via autoload.php or loading $this->load->library('session'); before use it.

不要忘记通过自动加载。php或$ this - >加载- >加载库(“会话”);之前使用它。

#2


0  

First change your application/config/config.php setting to:

第一个改变你的应用程序/配置/配置。php设置:

 $config['log_threshold'] = 1;
 $config['db_log_enabled'] = FALSE;

You'll get a more informative error in your log. You can find the logs in:

您将在日志中得到一个更有信息的错误。您可以在下面找到这些日志:

 /application/logs/

There is a CI bug involving ipv6 ip addresses. You are experiencing this bug if If the primary error looks like:

有一个CI bug涉及到ipv6 ip地址。如果主错误看起来像:

 ERROR - 2016-11-20 09:59:03 --> Severity: Warning --> mysqli::query(): (42000/3057): Incorrect user-level lock name 'longrandomsessionnamestring_2001:db8:1234:1:567::1'. /var/www/html/www/system/database/drivers/mysqli/mysqli_driver.php 305

You can verify that this is the issue by accessing your site directly via its ipv4 address (you should no longer get this error).

您可以通过其ipv4地址直接访问您的站点来验证这个问题(您不应该再得到这个错误)。

If you get the error via ipv6, but not via ipv4 you can alleviate the problem by setting

如果您通过ipv6而不是ipv4获得错误,您可以通过设置来缓解问题

 $config['sess_match_ip'] = FALSE;

or, better, apply CI hot fix #4916 to your CI code

或者,最好将CI热修复#4916应用到CI代码中

https://github.com/bcit-ci/CodeIgniter/commit/e49aa1f1cb63ad90d6c2d204439f538dcc282243

https://github.com/bcit-ci/CodeIgniter/commit/e49aa1f1cb63ad90d6c2d204439f538dcc282243

#1


1  

Change your application/config/config.php file setting to

改变你的应用程序/配置/配置。php文件设置

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessions';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';//its your table name name
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;

Read Session Preferences

读会话的偏好

Don't forget it to load via autoload.php or loading $this->load->library('session'); before use it.

不要忘记通过自动加载。php或$ this - >加载- >加载库(“会话”);之前使用它。

#2


0  

First change your application/config/config.php setting to:

第一个改变你的应用程序/配置/配置。php设置:

 $config['log_threshold'] = 1;
 $config['db_log_enabled'] = FALSE;

You'll get a more informative error in your log. You can find the logs in:

您将在日志中得到一个更有信息的错误。您可以在下面找到这些日志:

 /application/logs/

There is a CI bug involving ipv6 ip addresses. You are experiencing this bug if If the primary error looks like:

有一个CI bug涉及到ipv6 ip地址。如果主错误看起来像:

 ERROR - 2016-11-20 09:59:03 --> Severity: Warning --> mysqli::query(): (42000/3057): Incorrect user-level lock name 'longrandomsessionnamestring_2001:db8:1234:1:567::1'. /var/www/html/www/system/database/drivers/mysqli/mysqli_driver.php 305

You can verify that this is the issue by accessing your site directly via its ipv4 address (you should no longer get this error).

您可以通过其ipv4地址直接访问您的站点来验证这个问题(您不应该再得到这个错误)。

If you get the error via ipv6, but not via ipv4 you can alleviate the problem by setting

如果您通过ipv6而不是ipv4获得错误,您可以通过设置来缓解问题

 $config['sess_match_ip'] = FALSE;

or, better, apply CI hot fix #4916 to your CI code

或者,最好将CI热修复#4916应用到CI代码中

https://github.com/bcit-ci/CodeIgniter/commit/e49aa1f1cb63ad90d6c2d204439f538dcc282243

https://github.com/bcit-ci/CodeIgniter/commit/e49aa1f1cb63ad90d6c2d204439f538dcc282243