codeigniter-模型组由2个模型结果组成

时间:2012-12-18 06:27:50

标签: codeigniter

我有两个不同的模型函数event_person1和event_person5,我需要用event_id对两个模型的结果进行分组,模型在这里

public function event_person1($user_id){
$details1 ="select * from event where created_by={$user_id} order by created_date   desc";
$details = $this->db->query($details1);     
$res = $details->result_array();
return $res;
}

public function event_person5($employee_id,$user_id) {
$query="select distinct(event_id) from event_booth where booth_owner='{$employee_id}'";
$sql=$this->db->query($query);
$res=$sql->result_array();
$arr=array();
foreach($res as $r)
{ 
$data['id']=$r['event_id'];
$query1="select * from event where (event_id={$data['id']} and created_by!=      {$user_id})";
$sql1=$this->db->query($query1);
$res1=$sql1->result_array();
if(!empty($res1))
{
$arr[] = $res1;
}
unset($res1);
}
return $arr;
}

0 个答案:

没有答案