按codeigniter中array_merge中的a.bill_id id升序排列?

问题描述 投票:0回答:1
$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);

如何获得此查询上方的升序排列?

order by a.bill_id

php arrays postgresql sorting codeigniter
1个回答
0
投票

您可以使用

$this->db->order_by();
。尝试:
$this->db->order_by('a.bill_id','asc');

如果你想在 array_merge 之后对元素进行排序,你应该使用

array_multisort
,你可以在这里阅读更多相关信息

© www.soinside.com 2019 - 2024. All rights reserved.