$pid = input('?commentsPid') ? input('commentsPid') : 0;
$where = ['c.iid'=> input('id'),'c.pid'=> 0];
if($pid != 0){
$where['c.pid'] = $pid;
}
if(input('?searchVal') && input('searchVal') != ''){
$where['u.nickname'] = ['like','%' . input('searchVal') . '%'];
}
$list = Db::name('user_comments')->alias('c')
->join('tkh_user u ', 'c.uid=u.id')
->leftJoin('tkh_information i', 'c.iid=i.id')
->field('c.*,u.nickname,i.ti
->where($where)
->order('c.create_time desc')
->select()->toArray();
有searchVal值的时候切有匹配数据 ,查询不到数据; 不知道like要怎么写了;
在用个where 查询like 会报表达式错误,
最佳答案