1
$pag = $this->db->get('articles', $config['per_page'], $this->uri->segment(4));         
$data['records'] = $pag->result();

I already tried with

$pag = $this->db->get('articles', $config['per_page'], $this->uri->segment(4));         
$this->db->order_by('published', 'ASC');
$data['records'] = $pag->result();

either use ASC or desc I dont see any change.

Am I doing something wrong here?

Thanks

4

2 回答 2

3

尝试这个。将 order_by 语句移到顶部。

$this->db->order_by('published', 'ASC');
$pag = $this->db->get('articles', $config['per_page'], $this->uri->segment(4));         
$data['records'] = $pag->result();
于 2013-05-28T08:32:15.573 回答
3

问题在于:您在要求订购之前执行查询。
Order before 然后执行查询
当你做时:db->get你执行查询,如果你有 where 条件或 order 条件,你必须把它放在 get 命令之前。
尝试这个

$this->db->order_by('published', 'ASC');
$pag = $this->db->get('articles', $config['per_page'], $this->uri->segment(4));  
$data['records'] = $pag->result();

文档

于 2013-05-28T08:32:29.173 回答