我在我的模型中使用了以下查询,但是当我合并结果时,它只返回最后一个查询。
$this->db->where('type','user');
$this->db->where('status','Approve');
$this->db->select('*');
$this->db->from('trending_update');
$this->db->order_by('trending_update.update_time','DESC');
$this->db->join('user_profile', 'user_profile.id = trending_update.user_id');
$query = $this->db->get();
$data_user= $query->result();
$this->db->where('type','employer');
$this->db->where('status','Approve');
$this->db->select('*');
$this->db->from('trending_update');
$this->db->order_by('trending_update.update_time','DESC');
$this->db->join('event_master', 'event_master.employer_id = trending_update.user_id','left outer');
$this->db->join('employer_profile', 'employer_profile.id = trending_update.user_id','left outer');
$this->db->join('news_master', 'news_master.employer_id = trending_update.user_id','left outer');
$this->db->group_by('employer_profile.id');
$query = $this->db->get();
$data_employer = $query->result();
$data_all=$data_employer+$data_user;
答案 0 :(得分:0)
使用array_merge
php函数:
$this->db->where('type','user');
$this->db->where('status','Approve');
$this->db->select('*');
$this->db->from('trending_update');
$this->db->order_by('trending_update.update_time','DESC');
$this->db->join('user_profile', 'user_profile.id = trending_update.user_id');
$query = $this->db->get();
$data_user= $query->result_array();
$this->db->where('type','employer');
$this->db->where('status','Approve');
$this->db->select('*');
$this->db->from('trending_update');
$this->db->order_by('trending_update.update_time','DESC');
$this->db->join('event_master', 'event_master.employer_id = trending_update.user_id','left outer');
$this->db->join('employer_profile', 'employer_profile.id = trending_update.user_id','left outer');
$this->db->join('news_master', 'news_master.employer_id = trending_update.user_id','left outer');
$this->db->group_by('employer_profile.id');
$query = $this->db->get();
$data_employer = $query->result_array();
$data_all=array_merge($data_user,$data_employer);