tp5分页 搜索条件不保留/失效处理方法
thinkphp5.0分页 搜索条件不保留/失效解决
一般写法:分页跳转不包含搜索条件的
- $where = array();
- $regionId = input('regionId/d');
- $regionId && $where['regionId'] = $regionId;
- $num = input('num');
- $num && $where['num'] = $num;
- $lists = Region::where($where)->paginate(15,'',array('page' => input('param.page')));
- $this->assign('lists', $lists);
- return $this->fetch();
需要保留搜索条件的正确写法:query参数
- $where = array();
- $regionId = input('regionId/d');
- $regionId && $where['regionId'] = $regionId;
- $num = input('num');
- $num && $where['num'] = $num;
- $lists = Region::where($where)->paginate(15,'',array('page' => input('param.page'),'query'=>$where));
- $this->assign('lists', $lists);
- return $this->fetch();
本文作者:未来往事
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处
此处评论已关闭