|
@@ -1438,6 +1438,27 @@ class Query
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
+ //模仿上一个page,但是从paginate拿到page与list_rows
|
|
|
+ public function autopage(){
|
|
|
+ $config = Config::get('paginate');
|
|
|
+
|
|
|
+ /** @var Paginator $class */
|
|
|
+ $class = false !== 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;
|
|
|
+
|
|
|
+ //list_rows
|
|
|
+ $listRows = isset($_REQUEST['listrow']) ? (int)$_REQUEST['listrow'] : $config['list_rows'];
|
|
|
+
|
|
|
+
|
|
|
+ $this->options['page'] = [intval($page), intval($listRows)];
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 分页查询
|
|
|
* @param int|array $listRows 每页数量 数组表示配置参数
|