## ThinkPHP5 自带分页无其他筛选参数
#### 这里为paginate的代码,通过检查传入的参数$config
```php
/**
* 分页查询
* @param int|null $listRows 每页数量
* @param bool $simple 简洁模式
* @param array $config 配置参数
* page:当前页,
* path:url路径,
* query:url额外参数,
* fragment:url锚点,
* var_page:分页变量,
* list_rows:每页数量
* type:分页类名,
* namespace:分页类命名空间
* @return \think\Paginator
* @throws DbException
*/
public function paginate($listRows = null, $simple = false, $config = [])
{
$config = array_merge(Config::get('paginate'), $config);
$listRows = $listRows ?: $config['list_rows'];
$class = strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']);
$page = isset($config['page']) ? (int) $config['page'] : call_user_func([
$class,
'getCurrentPage',
], $config['var_page']);
$page = $page < 1 ? 1 : $page;
$config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']);
/** @var Paginator $paginator */
if (!$simple) {
$options = $this->getOptions();
$total = $this->count();
$results = $this->options($options)->page($page, $listRows)->select();
} else {
$results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select();
$total = null;
}
return $class::make($results, $listRows, $page, $total, $simple, $config);
}
```
### 因此我们在调用paginate这个方法时传入请求参数即可
```php
// 在模型调用时加入请求参数
public function getList($where, $page, $limit)
{
return $this->where($where)->page($page)->order('sort desc')->order('id desc')->paginate($limit, false, [
'query' => request()->param(),
]);
}
```
// 在模型调用时加入请求参数
public function getList($where, $page, $limit)
{
return $this->where($where)->page($page)->order('sort desc')->order('id desc')->paginate($limit, false, [
'query' => request()->param(),
]);
}