我想在cakephp 3.8中进行分页。示例数据响应:
{“成功”:是的,“数据”:[]}
我需要数据响应:
{“成功”:是的,“数据”:[],“分页”:{“ page_count”:13“当前页”:1“计数”:25,“ has_prev_page”:否,“ has_next_page”:是}}
谢谢。
这是我的下面的代码:
<pre>
return $this->responseData(__('success'), $this->paginate($projects) ?? []);
</pre>
您可以在调用$this->paginate()
的请求对象after中找到分页元数据,它存储在名为paging
的参数中:
$data = $this->paginate($projects) ?? [];
$pagination = $this->getRequest()->getParam('paging');
另请参见