我收到此错误,有人知道这可能是什么原因吗?我认为它与模型有关,但无法弄清楚。
Error Number: 1054
Unknown column 'id' in 'order clause'
SELECT * FROM (
tblquestions) ORDER BY
idasc 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/