How to add an ORDER BY clause using CodeIgniter's Active Record methods?

后端 未结 5 2293
萌比男神i
萌比男神i 2020-11-29 02:32

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->         


        
5条回答
  •  孤独总比滥情好
    2020-11-29 02:49

    function getProductionGroupItems($itemId){
         $this->db->select("*");
         $this->db->where("id",$itemId);
         $this->db->or_where("parent_item_id",$itemId);
    
        /*********** order by *********** */
         $this->db->order_by("id", "asc");
    
         $q=$this->db->get("recipe_products");
         if($q->num_rows()>0){
             foreach($q->result() as $row){
                 $data[]=$row;
             }
             return $data;
         }
        return false;
    }
    

提交回复
热议问题