我得到这个错误有人知道是什么可能是这个原因吗?我想是模型出了问题,但我不明白。
错误编号:1054
order子句中未知列'id'
SELECT * FROM (
tblquestions) ORDER BY
idasc LIMIT 5
文件名:C: ' wamp ' www数据库'苏尔'系统' ' DB_driver.php
行号: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 as:
SELECT * FROM (tblquestions) ORDER BY qid asc LIMIT 5
包括使用order by, having, group by
子句时要选择的所有列。比如—— SELECT ID FROM (tblquestions) ORDER BY ID asc LIMIT 5
或者如果你也想这样做SELECT * FROM (tblquestions) ORDER BY tblquestions.ID asc LIMIT 5
在应用order by, having, group by
子句之前必须特别选择ColumnName .
Here you can change this---
$this->db->order_by($this->primary_key,'asc'); to
$this->db->order_by("tblquestions".$this->primary_key,'asc');