How to add an ORDER BY clause using CodeIgniter's Active Record methods?

后端 未结 5 2309
萌比男神i
萌比男神i 2020-11-29 02:32

I have a very small script to get all records from a database table, the code is below.

$query = $this->db->get($this->table_name);
return $query->         


        
5条回答
  •  甜味超标
    2020-11-29 02:47

    Just add the'order_by' clause to your code and modify it to look just like the one below.

    $this->db->order_by('name', 'asc');
    $result = $this->db->get($table);
    

    There you go.

提交回复
热议问题