如何获取分页元数据?

问题描述 投票:0回答:1

我想在cakephp 3.8中进行分页。示例数据响应:

{“成功”:是的,“数据”:[]}

我需要数据响应:

{“成功”:是的,“数据”:[],“分页”:{“ page_count”:13“当前页”:1“计数”:25,“ has_prev_page”:否,“ has_next_page”:是}}

谢谢。

这是我的下面的代码:

<pre>
  return $this->responseData(__('success'), $this->paginate($projects) ?? []);
</pre>
cakephp pagination cakephp-3.x
1个回答
0
投票

您可以在调用$this->paginate()的请求对象after中找到分页元数据,它存储在名为paging的参数中:

$data = $this->paginate($projects) ?? [];
$pagination = $this->getRequest()->getParam('paging');

另请参见

© www.soinside.com 2019 - 2024. All rights reserved.