筛选条件判断
public function helplist() { $int = Request::param('fl'); $recommend = Request::param('fl2'); $time = Request::param('time'); if ([$int == 'kong', $recommend == 'kong', $time == null]) { /* $this->error('wei匹配结果', '/admin/background/helplist');*/ } /*$aaa = array();*/ 、//定义一个空数组 $aaa = []; //定义一个空数组 if ($int != null) { // array_push($aaa, ['a.id','=', $int]); $aaa[] = ['a.id', '=', $int]; // []是追加的进数组中 } if ($time != null) { $statime = explode(" - ", $time); $statime = strtotime($statime[0]); $endtime = strtotime($statime[1]); //array_push($aaa, ['w.time', 'between', [$statime, $endtime]]); $aaa[] = ['w.time', 'between', [$statime, $endtime]]; } if ($recommend != null) { //array_push($aaa, ['w.recommend', '=', $recommend]); $aaa[] = ['w.recommend', '=', $recommend]; } $data = Db::table('classify') ->alias('a') ->join(['hf_help' => 'w'], 'a.id=w.classifyId') ->where($aaa) ->order(['w.id' => 'desc']) ->paginate(15, false, [ 'query' => request()->param()]); $classify = Db::table('classify') ->select(); $page = $data->render(); $data = $data->items(); $this->view->assign('page', $page); $this->view->assign('date', $data); $this->view->assign('classify', $classify); return $this->view->fetch('helplist'); }