ThinkPHP5 分页 搜索条件不保留/失效处理方法

  • A+
所属分类:PHP ThinkPHP

一般写法:分页跳转不包含搜索条件的

$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();
  • 免费领红包
  • 支付宝红包扫一扫
  • weinxin
  • 免费提现
  • 支付宝全额提现
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: