HUX布斯
$data=Db::name($this->name)->field('id',sender)->where($where)->select();
if(empty($data)) return [];
$data_sender_ids=array_unique(array_column($data,'sender'));
$model_member=new Member();
$data_members=$model_member->field(...)
->whereIn('id',$data_sender_ids)
->where(delstatus,'<>',2)
->get();
if(empty($data_members)) return [];
$sender_ids=array_column($data_members,'id');
foreach($data as $key=>$value){
if(!in_array($value['sender'],$sender_ids)){
unset($data[$key]);
}
}
return $data;
两条sql搞定
//我不清楚你的php框架,这段代码你变通一下
$data_members=$model_member->field(...)
->whereIn('id',$data_sender_ids)
->where(delstatus,'<>',2)
->get();