I have database of library and I would like to display Book detail. Document hasMany Articles and Article hasAndBelongsToMany Authors. In ArticlesController I can see Authors of Articles, but I do not know how to access them in DocumentsController.
Asked
Active
Viewed 42 times
1 Answers
2
You need to set the property $recursive to something like 2
$this->Document->recursive = 2;
$this->Document->find('all');
OR you can also use containable behavior
$this->Document->Behaviors->load('Containable');
$this->Document->find('all', array('contain' => array('Article' => 'Author')));

Guillermo Mansilla
- 3,779
- 2
- 29
- 34
-
Thanks a lot, I had it a little bit different and it finally works. – Andrew Nov 23 '13 at 19:43
-
Containable is the suggested behavior. Recursive gets **all** associated data, including much garbage data you don't need. – Oldskool Nov 23 '13 at 21:11
-
Yeah, that's why I gave both options – Guillermo Mansilla Nov 24 '13 at 00:29