Вопрос

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.

Это было полезно?

Решение

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')));
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top