TopTomato
TopTomato

Reputation: 585

how to use CodeIgniter's order_by method?

how to check if the order_by method implemented in CodeIgniter? i tried with several variations on the code below, none of which worked

 function getPRs(){
    $this->db->from('press_releases');
    $this->db->order_by('sort_order', 'asc');
    $query = $this->db->get();
    return $query->result();
 }

any help on this would be greatly appreciated!, thanks

Upvotes: 0

Views: 63

Answers (2)

jagruti
jagruti

Reputation: 390

Please try this code once.

    $this->db->select('*');        
    $this->db->from('press_releases');        
    $this->db->order_by('sort_order', 'asc'); 
    $query = $this->db->get();
    return $query->result_array();

Upvotes: 2

zied.hosni
zied.hosni

Reputation: 490

try this

 function getPRs(){
    $this->db->order_by('sort_order', 'asc');
    $query = $this->db->get('press_releases');
    return $query->result();
 }

Upvotes: 0

Related Questions