【发布时间】:2016-05-08 15:34:33
【问题描述】:
我正在尝试对类别表使用树行为。我刚刚使用蛋糕烘焙创建了model、controller、categoryTable、category.php。它正在工作,但我试图将所有孩子都放在他的父母之下,在阅读了 cakebake 书后,我知道->find('threaded') 可以做到这一点。但它给出了错误。
错误是:
传递的变量不是数组或对象,而是使用空数组
完整的查询是:
$parentCategory = $this->Category->ParentCategory->find('list', ['limit' => 200])->find('threaded');
它给出了错误,但如果我删除 ->find('threaded') 则没有错误,但它会以与保存相同的顺序显示数据。
目前工作如下;
Parent 1
child 1
child 2
Parent 2
child 1
child 2
child 3(from parent 1)
虽然我想显示如下
parent 1
child 1
child 2
child 3
parent 2
child 1
child 2
【问题讨论】:
标签: cakephp tree cakephp-3.0