TP5混合查询 and or 联合查询写法
$keyword = $post['keyword']; $keyword=isset($keyword) && !empty($keyword) ? trim($keyword) : null; $where=[]; if(!is_null($keyword)){ $where['u.nikename | f.remarks | u.user_login'] = ['like', "%" . $keyword . '%']; } $where['f.user_id'] = 1; $res = db('focuses')->alias('f')->join('users u','f.fans_id = u.id','LEFT')->where($where)->select();
其实就是这个or的关系问题,用这种方式就可以啦