thinkphp6 分页加参数
2022-11-24 11:10:29
175
{{single.collect_count}}
//控制器方法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()]);

这能解决做搜索功能的时候,搜索出来的数据分页后,按第二页又显示非搜索数据的问题

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}