function index() {
$info['title'] = 'Browser Title';
$info['heading'] = 'Blog Heading';
$info['query'] = $this->db->get('entries');
$info['query']开发者_StackOverflow社区 = $this->db->order_by('id', 'asc');
$this->load->view('blog_view', $info);
}
I'm creating a mini blog app from a tutorial and wanted to add in the option of displaying blog entries in order of ascending or descending by id. The code above gives me an error but I pasted it up here hoping someone would be able to show me the correct way to do it. I've consulted the CI user manual but couldn't find any specific examples of what I"m looking for, which makes it somewhat confusing for a newbie like me.
It looks like the order is wrong, put the order-by first without the $info['query']
$info['title'] = 'Browser Title';
$info['heading'] = 'Blog Heading';
$this->db->order_by('id', 'asc');
$info['query'] = $this->db->get('entries');
精彩评论