From e093a6661e6df3c6731d0cfcaad89f663265fc5a Mon Sep 17 00:00:00 2001 From: yunwuxin <448901948@qq.com> Date: Wed, 18 May 2016 16:51:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5=E7=9A=84=E6=AF=8F=E9=A1=B5?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=85=A8=E5=B1=80=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 5 +++-- library/think/db/Query.php | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/convention.php b/convention.php index d13b730c..55f2d50b 100644 --- a/convention.php +++ b/convention.php @@ -209,8 +209,9 @@ return [ ], //分页配置 'paginate' => [ - 'type' => 'bootstrap', - 'var_page' => 'page', + 'type' => 'bootstrap', + 'var_page' => 'page', + 'list_rows' => 15 ], ]; diff --git a/library/think/db/Query.php b/library/think/db/Query.php index d55c2161..59fd6393 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -744,7 +744,7 @@ class Query /** * 分页查询 - * @param int $listRows 每页数量 + * @param int|null $listRows 每页数量 * @param bool $simple 简洁模式 * @param array $config 配置参数 * page:当前页, @@ -752,15 +752,18 @@ class Query * query:url额外参数, * fragment:url锚点, * var_page:分页变量, + * list_rows:每页数量 * type:分页类名, * namespace:分页类命名空间 * @return \think\paginator\Collection * @throws DbException */ - public function paginate($listRows = 15, $simple = false, $config = []) + public function paginate($listRows = null, $simple = false, $config = []) { $config = array_merge(Config::get('paginate'), $config); + $listRows = $listRows ?: $config['list_rows']; + $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\paginator\\driver\\') . ucwords($config['type']); $page = isset($config['page']) ? (int) $config['page'] : call_user_func([