//控制器方法public function index(){$data['logmin'] = isset($_GET['logmin'])?strtotime($_GET['logmin']):'';$data['logmax'] = isset($_GET['logmax'])?strtotime($_GET['logmax']):'';$data['title']= isset($_GET['title']) ? trim($_GET['title']) : '';$list = Banners::listInfo($data);// $page = $list->render();$position = ['首页','新闻中心','走进为尔','明星产品','联系我们'];View::assign('position',$position);View::assign('list',$list);// View::assign('page',$page);return View::fetch();}//模型方法public static function listInfo($data){$where = [];if(!empty($data['title'])){$where[]=['title','like',"%".$data['title']."%"];}switch(true){case !empty($data['logmin'])&&!empty($data['logmax']):$where[]=['posttime','between',[$data['logmin'],$data['logmax']]];break;case !empty($data['logmin']):$where[]=['posttime','>=',$data['logmin']];break;case !empty($data['logmax']):$where[]=['posttime','<',$data['logmax']];break;}$res =Db::table('Banner')->where($where)->paginate(['list_rows'=>2,'query' => request()->param()]);return $res;}
thinkphpphp6 分页传参用的不是->paginate(2, false, ['query' => request()->param()]);
而是->paginate(['list_rows'=>2,'query' => request()->param()]);
这能解决做搜索功能的时候,搜索出来的数据分页后,按第二页又显示非搜索数据的问题