Saturday, July 4, 2009

backward recursion possible?

When setting the recursive variable cakephp seems to fetch associated
model data only in one direction. But I need it to go back at a
certain point.
Let's say we have 2 associated models:

Bus hasAndBelongsToMany Person.

If I do use §this->Bus->find() in the Bus Controller I get the
associated Persons to each Bus.
The resulting array is something like this:

Array
(
[0] => Array
(
[Bus] => Array
(
[id] => 1
)

[Person] => Array
(
[0] => Array
(
...


But now in addition I want to have the associated Buses for each
Person. The resulting array should be something like this:

Array
(
[0] => Array
(
[Bus] => Array
(
[id] => 1
)

[Person] => Array
(
[0] => Array
(
[id] => 1

[Bus] => Array
(
[0] => Array
(
[id] => 1


How is this possible in cakePHP?
I have tried to use contain but it simply ignores the last array:

$this->Bus->find("all"
,array('contain'=>array("Person"=>array("Bus"))));

Please help, I am going nuts!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: