gpt4 book ai didi

php - codeigniter 中的数据库错误 1054

转载 作者:可可西里 更新时间:2023-11-01 00:20:03 24 4
gpt4 key购买 nike

我正在尝试做一个 OTH 应用程序,但我收到了这个错误

A Database Error Occurred

Error Number: 1054

Unknown column 'data' in 'field list'

SELECT data FROM ci_sessions WHERE id = 'dd8fddaabb45c365fbf27a6fdc5ea60d59f569e4' AND ip_address = '::1'

Filename: libraries/Session/drivers/Session_database_driver.php

Line Number: 160

这是 Session_database_driver.php

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)
{
$this->_fingerprint = md5('');
return '';
}

// PostgreSQL's variant of a BLOB datatype is Bytea, which is a
// PITA to work with, so we use base64-encoded data in a TEXT
// field instead.
$result = ($this->_platform === 'postgre')
? base64_decode(rtrim($result->data))
: $result->data;

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

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

最佳答案

根据关于 Sessions 的 CI 手册基本格式ci_sessions 表的内容是:

CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);

在您的 php 代码中,您使用了不同的字段:

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

因此,通过将该代码更改为:

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

您的代码应该可以工作。

关于php - codeigniter 中的数据库错误 1054,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29764089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com