0

I want to retrieve tree nodes recursively and want to join each [Node] with [Level]
Node:

 ...
public $belongsTo = array(
    'Parent' => array(
        'className' => 'Node',
        'foreignKey' => 'parent_id'
    ),
    'Level' => array(
        'className' => 'Level',
        'foreignKey' => 'level_id'
    )
);
 ...

Controller:

$this->Node->contain(array(
        'Parent.Parent.Parent.Parent.Parent',
    ));
$parentTree = $this->Node->findAllById($id);

the recursion works already but I want each Node to have a Level element and now it's not the case.
How would be the correct contain parameter?
Levels are recursive as well but in this case a want to restrict the recursion - need only the first one

jeff
  • 1,169
  • 1
  • 19
  • 44
  • You don't want to use recursive at all. Set it to `-1` in your AppModel and thank me later. – Dave May 29 '14 at 20:27
  • a bit more explaination? – jeff May 30 '14 at 09:11
  • I would explain more, but I really don't understand your question. You mention recursion, but don't show what it's set to. Then you have a very strange contain and you don't show what results you're hoping for. – Dave May 30 '14 at 13:53
  • I have a tree of nodes which can be 6 levels deep and I want to fetch all the precessors – jeff May 30 '14 at 14:01
  • Are you using the built in Tree behavior? – Dave May 30 '14 at 18:13

0 Answers0