How to add an ORDER BY clause using CodeIgniter's Active Record methods?
Asked 07 September, 2021
Viewed 1.1K times
  • 55
Votes

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->result();

Using this syntax, how would I add a ORDER BY 'name' clause to my select query?

I get errors every time I stick the order by bit on the end.

5 Answer