在codeigniter中的array_merge中由a.bill_id id升序?

时间:2015-12-11 09:46:35

标签: postgresql codeigniter

$this->db->select('b.name as user_name,a.bill_id,a.dat,a.bill_id,a.buyer_typ');    
$this->db->from('tra_books_sales_head a'); 
$this->db->join('mas_staff_head b','b.staff_id = a.staff_id');  
$query1 = $this->db->get()->result();

$this->db->select('a.customer_name as user_name,a.bill_id,a.dat,b.bill_id,a.buyer_typ'); 
$this->db->distinct();          
$this->db->from('tra_books_sales_head a');
$this->db->join('tra_books_sales_dt b','b.bill_id = a.bill_id');
$this->db->where('a.customer_name is not NULL');       
$query2 = $this->db->get()->result();
return $query =array_merge($query1,$query2);

如何在此查询之上获得升序。 按a.bill_id排序

1 个答案:

答案 0 :(得分:0)

您可以使用$this->db->order_by();。尝试: $this->db->order_by('a.bill_id','asc');

如果你想在array_merge之后订购元素,你应该使用array_multisort,你可以阅读更多关于它的信息here