1
我有两个模型之间的HABTM关联,但只能找到返回一个级别。我可以与其他协会一起返回几个级别,但认为我必须用HABTM丢失一些东西。CakePHP多个HABTM协会在容易找到
控制器/ SchedulesController.php
$this->Schedule->find('first', array(
'contain' => array(
'Association' => array(
'Schedule'
)
)
));
型号/ Schedule.php
public $actsAs = array('Containable');
public $hasAndBelongToMany = array(
'Association'
);
型号/ Association.php
public $actsAs = array('Containable');
public $hasAndBelongsToMany = array(
'Schedule'
);
目前我只得到...
array(
'Schedule' => array(
...
),
'Association' => array(
(int) 0 => array(
...
'AssociationsSchedule' => array(
...
)
)
)
...但我想表 - >协会 - >预定
为什么你想要两次相同的数据? –