fix: 分页转换int类型

This commit is contained in:
Ying
2022-11-28 22:30:30 +08:00
parent 63a90c701a
commit 3c98edcdd8
3 changed files with 5 additions and 5 deletions

View File

@@ -56,7 +56,7 @@ class AdminGroup extends AdminController
$count = $this->model->where($where)->count(); $count = $this->model->where($where)->count();
$limit = is_empty($param['limit']) ? 10 : (int)$param['limit']; $limit = is_empty($param['limit']) ? 10 : (int)$param['limit'];
$page = ($count <= $limit) ? 1 : $param['page']; $page = ($count <= $limit) ? 1 : $param['page'];
$list = $this->model->where($where)->order("id asc")->limit($limit)->page($page)->select()->toArray(); $list = $this->model->where($where)->order("id asc")->limit((int)$limit)->page((int)$page)->select()->toArray();
foreach ($list as $key => $value) { foreach ($list as $key => $value) {
$list[$key]['title'] = __($value['title']); $list[$key]['title'] = __($value['title']);
} }

View File

@@ -37,8 +37,8 @@ class UserGroup extends AdminController
if (request()->isAjax()) { if (request()->isAjax()) {
$param = input(); $param = input();
$param['page'] = input('page/d'); $param['page'] = input('page/',1);
$param['limit'] = input('limit/d'); $param['limit'] = input('limit',10);
// 查询条件 // 查询条件
$where = array(); $where = array();
@@ -54,9 +54,9 @@ class UserGroup extends AdminController
// 查询数据 // 查询数据
$count = $this->model->where($where)->count(); $count = $this->model->where($where)->count();
$limit = is_empty($param['limit']) ? 10 : $param['limit']; $limit = empty($param['limit']) ? 10 : $param['limit'];
$page = ($count <= $limit) ? 1 : $param['page']; $page = ($count <= $limit) ? 1 : $param['page'];
$list = $this->model->where($where)->order("id asc")->limit($limit)->page($page)->select()->toArray(); $list = $this->model->where($where)->order("id asc")->limit($limit)->page((int)$page)->select()->toArray();
foreach ($list as $key => $value) { foreach ($list as $key => $value) {
$list[$key]['title'] = __($value['title']); $list[$key]['title'] = __($value['title']);
} }