Thinkphp5 闭包函数query传参查询
$res0=Comment::all(function($query) use ($id){
$query->where("postid","=",$id)->order('date DESC')->alias('c')->join('cy_oauth_user o','o.id = c.ouid')->field("c.id,c.pid,c.content,c.like,c.date,c.ouid,o.nickname,o.head_img,o.is_vip,o.is_admin");
});
foreach($res0 as $val){
$CommentArr[]=$val->toArray(); //打印出多条一维数组
}
$this->assign('countcomm',count($CommentArr));
return $this->fetch();
传两个参数的方法
$this->where(function ($query) use ($id1, $id2){
$query->where('id', $id1)->whereor('id', $id2);
})->find();