gpt4 book ai didi

php - CRUD应用程序上的错误号1054

转载 作者:行者123 更新时间:2023-12-03 08:34:05 24 4
gpt4 key购买 nike

我收到此错误,有人知道这可能是什么原因吗?我认为它与模型有关,但无法弄清楚。

Error Number: 1054

Unknown column 'id' in 'order clause'

SELECT * FROM (tblquestions) ORDER BY id asc LIMIT 5

Filename: C:\wamp\www\Surva\system\database\DB_driver.php

Line Number: 330


模型
private $primary_key = 'QID';
private $table_name = 'tblquestions';

function get_paged_list($limit=10, $offset=0, $order_column='', $order_type='asc')
{
if (empty($order_column) || empty($order_type)) {
$this->db->order_by($this->primary_key, 'asc');
}
else {
$this->db->order_by($order_column, $order_type);
return $this->db->get($this->table_name, $limit, $offset);
}
}

function count_all()
{
return $this->db->count_all($this->table_name);
}

function get_by_id($id)
{
$this->db->where($this->primary_key, $id);
return $this->db->get($this->table_name);
}

function save($question)
{
$this->db->insert($this->table_name, $question);
return $this->db->insert_id();
}

function update($id,$question)
{
$this->db->where($this->primary_key, $id);
$this->db->update($this->table_name, $question);
}

function delete($id)
{
$this->db->where($this->primary_key, $id);
$this->db->delete($this->table_name);
}

最佳答案

请将id更改为qid为:

      SELECT * FROM (tblquestions) ORDER BY qid asc LIMIT 5

您在查询中输入了错误的列名。

关于php - CRUD应用程序上的错误号1054,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15427729/

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