【问题标题】:CakePHP deeper recursiveCakePHP 更深层次的递归
【发布时间】:2012-08-24 20:08:57
【问题描述】:

我有以下问题。 我有以下关系: A->B->C->D 与模型中的各自关系。 我需要得到所有属于“A”的“D”

$this->A->B->C->D->find('all', array ('conditions' =>
    array('B.a_id' => $id)
));

但得到 b.a_id 的错误。

我试过递归 = 2;

但我一直遇到同样的问题。

我做错了什么? PD:对不起,我的英语不好

【问题讨论】:

  • 他们都是belongs_to吗?你试过递归 3 吗?

标签: cakephp recursive-datastructures


【解决方案1】:

也许更好的办法是将模型 A、B、C、D 连接到您的控制器。

在您的控制器中:

var $uses = array('A', 'B', 'C', 'D');
$this->D->recursive = 2;
$result = $this->D->find('all', array ('conditions' => array('B.a_id' => $id)));

如果不是这样,请尝试查找所有 D,然后在调试 $result 变量时创建条件:

$result = $this->D->find('all');
debug($result);
die;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-07
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-03
    相关资源
    最近更新 更多