1. 程式人生 > >thinkphp5展示查詢分頁帶條件

thinkphp5展示查詢分頁帶條件

public function gcbq(Request $request){      
        $data['name']=$request->param('name');
        $data['busname']=$request->param('busname');
        (!empty($request->param('name'))) ? $where1 = [ 'name' => $request->param('name')]:$where1=[];
        (!empty($request->param('busname'
))) ? $where2 = [ 'busname' => $request->param('busname')]:$where2=[]; $res=Db::table('gc_con')->alias('a') ->join('gc_goods go','a.goodsid=go.goodsid','left') ->join('gc_store st','a.busid=st.busid', 'left') ->field('a.id,go.name,st.busname,a.bq,a.bqo,a.bqt,a.path,a.money'
) ->where($where1) ->where($where2) ->paginate(6,false,['query'=>$data]); //->select(); $pagelist=$res->render(); $this->assign(['list'=>$res,'pagelist'=>$pagelist,'data'=>$data]); return $this->fetch('store/gcconlist'
); }