我使用CodeIgniter来完成这项工作。我不知道为什么它不起作用:X有什么建议吗?
$this->db->from("twitch");
$this->db->where(array('banned' => 0));
$this->db->order_by("viewers", "DESC");
$this->db->limit($limit, $start);
$query = $this->db->get();结果不是由查看者DESC (或在主页上-0查看者和在最后一页- 2000查看者)排序的
模型功能- http://pastebin.com/yqwvZEQ1视图- http://pastebin.com/gL95uDR6
发布于 2013-12-30 20:18:05
试着这样做:
$this->db->from('twitch')->where('banned'=>0)->order_by("viewers", "DESC")->limit($limit, $start);
$query = $this->db->get();尝试使用codeigniter的链接方法。有关更多信息,请参阅文档:http://ellislab.com/codeigniter/user-guide/database/active_record.html#select
发布于 2013-12-30 20:21:13
$query = $this->db->
where(array('banned' => 0))->
order_by('viewers', 'DESC')->
limit($limit, $start)->
get('twitch');你使用MySQL吗?因为这种LIMIT语法只适用于MySQL。还要确保已经定义了$limit和$start的值。
发布于 2013-12-30 20:12:00
试试这个:
$this->db->limit($limit, $start);
$this->db->order_by("viewers", "DESC");
$this->db->where("banned", "0"));
$query = $this->db->get("twitch");只是更改了所用函数的顺序。limit应该是第一个-否则它不会限制*未排序*未*过滤的数据。
https://stackoverflow.com/questions/20839210
复制相似问题