codeigniter order by
$this->db->select('*');
$this->db->from('your_table_name');
$this->db->order_by('column_name', 'asc'); // Replace 'column_name' with the actual column name you want to order by
$query = $this->db->get();
$result = $query->result();
Explanation:
$this->db->select('*');
: Specifies that all columns should be selected in the query.$this->db->from('your_table_name');
: Specifies the table from which to retrieve the data, replace 'your_table_name' with the actual name of your table.$this->db->order_by('column_name', 'asc');
: Specifies the order in which the result should be sorted. Replace 'column_name' with the actual column name you want to use for ordering. 'asc' stands for ascending order, you can use 'desc' for descending order.$query = $this->db->get();
: Executes the query and stores the result in the$query
variable.$result = $query->result();
: Fetches the result of the query and stores it in the$result
variable. The result can be iterated through as an array of objects.