【发布时间】:2015-11-09 22:35:19
【问题描述】:
分页时限制包含的关联记录数的正确方法是什么?
The docs don't appear to address 如何在分页时设置“包含”选项,但$paginate['contain']['AssociatedModel']['limit'] = 1; 似乎很有意义。但是,该行导致我在 CakePHP 3.1.3 中出现以下错误:
Fatal error: Unsupported operand types in ...\vendor\cakephp\cakephp\src\ORM\EagerLoader.php on line 312
之所以会产生错误,是因为在$pointer[$table] = $options + $pointer[$table]; 行中,$options 是1,而$pointer[$table] 是一个数组。
令人困惑的是,设置 $paginate['contain']['AssociatedModel']['fields'] 可以按预期工作,但设置 'limit' 或 'order' 会导致同样的错误。
【问题讨论】:
标签: cakephp cakephp-3.1 cakephp-3.x