我有三个模型:协会HasMany服务服务HasBelongs协会和HasMany成员HasBelongs服务
我希望通过关联找到成员,但我通过关联找到服务。
$associations = $this->Member->Service->Association->find('all',
array(
'fields'=>array('id','libelle')
));调试结果为:
array(
(int) 0 => array(
'Association' => array(
'id' => '1',
'libelle' => 'الادارة العامة للصحة العسكرية'
),
'Service' => array(
(int) 0 => array(
'id' => '1',
'libelle' => 'Divers',
'association_id' => '1'
),
(int) 1 => array(
'id' => '2',
'association_id' => '1'
),
(int) 2 => array(
'id' => '3',
'libelle' => 'مكتب الضبط BO',
'association_id' => '1'
)
)
),
(int) 1 => array(
'Association' => array(
'id' => '2',
'libelle' => 'أعضاء الديوان والمديرين'
),
'Service' => array()
),
(int) 2 => array(
'Association' => array(
'id' => '3',
'libelle' => 'المستشفات والمراكز والمصحات '
),
'Service' => array()
),
(int) 3 => array(
'Association' => array(
'id' => '4',
'libelle' => 'المستشفى العسكري الاصلي للتعليم '
),
'Service' => array()
)我想通过关联查找成员例如:所有属于协会الادارةالعامةللصحةالعسكرية的成员,即服务1,2,3的所有成员
发布于 2015-07-10 22:42:48
你可以使用“contain”来做这件事。书中有一些例子:http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html
https://stackoverflow.com/questions/31205301
复制相似问题