查询数据拼接返回
2018-09-21 17:52:17 来源:admin 点击:870
$smsList = DB::table('表 as a')
->where('a.uid',$uid)
->select('a.id','a.title','a.uid','a.username','a.time','a.people')
->where('a.status',0);
$listNum = $smsList->get()->count();
$list = $smsList->limit($pageSize)->offset($pageIndex)->get();
foreach ($list as $key => $v){
$peopel = explode(',',$v->people);
foreach ($peopel as $key1=>$vv){
$username[$key][] = DB::table('user')->where('id',$vv)->value('username');
}
$data[]=[
'title'=>$v->title,
'username'=>$username[$key],
'time'=>$v->time
];
}
查询完一个数据后,但结果不是自己想要的,还要在循环遍历查找想要的东西,但查出的内容有事一个数组或集合没有使用上述方法