【发布时间】:2015-10-31 16:43:49
【问题描述】:
根据文档http://book.cakephp.org/3.0/en/controllers/components/pagination.html,我想对如下查询的结果进行分页:
$unlocked_sitesQuery = $this->Deviceconnections
->find()
->contain([
'Agthemes.Sites',
'Agthemes.Agpois',
'Agthemes.Agthemelanguages'
])
->where(['request' => 'unlock'])
->groupBy('agtheme.site.id');
$unlocked_sites = $this->paginate($unlocked_sitesQuery);
但我收到以下错误:
错误:调用未定义的方法
ArrayIterator::alias()文件 /home/mywebsite/vendor/cakephp/cakephp/src/Controller/Component/PaginatorComponent.php
线路:154
什么意思?
编辑 @ndm 似乎是对的,但文档说:
默认情况下,
paginate()方法将使用控制器的默认模型。您还可以传递 find 方法的结果查询:
public function index()
{
$query = $this->Articles->find('popular')->where(['author_id' => 1]);
$this->set('articles', $this->paginate($query));
}
所以它应该适用于结果集。或者我不明白医生解释了什么。可能。
【问题讨论】:
标签: cakephp orm pagination cakephp-3.0