Rasi
answered Apr 27 '23 00:00
To avoid duplicating the $this->db->order_by() method call, you can pass an array of column names and sorting directions to the method.
Here's an example of how to use an array to avoid duplicating the $this->db->order_by() method call:
$this->db->select('*');
$this->db->from('my_table');
$this->db->where('my_column', $my_value);
$this->db->order_by(array('my_column1' => 'ASC', 'my_column2' => 'DESC'));
$query = $this->db->get();