Tags
Asked 3 years ago
17 Jun 2021
Views 214
Dallin

Dallin posted

query using two order by in codeigniter

query using two order by in codeigniter
Rasi

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();
Post Answer