$data = DB::name('collect')
->alias('a')
->leftJoin('products b','a.pid=b.id')
->leftJoin('member c','c.id=a.uid')
// ->where('a.uid',$uid)
->field('a.uid,b.id,b.uid as b_uid,b.proname,thumb,b.price,b.type,a.create_time as com,b.uid as user')
// ->field('a.*,c.*,c.id as c_id')
->order('a.id desc')
->page($pre,10)
->select();
$count =0;
foreach($data as $k=>$v){
if($uid !== (string)$v['b_uid'])
{
return json(['status' => 3, 'data' => '', 'msg' => '暂无点赞!']);
}
$shopid =$v['uid'];
$data[$k]['user'] = db::name('member')->where('id',$shopid)->find();
$count++;
$data[$k]['number'] =0;
}
if(!isset($data)){
return json(['status' => 3, 'data' => '', 'msg' => '暂无点赞!']);
}
}
```
\
简单的联表查询
最新推荐文章于 2022-01-21 16:04:44 发布