这是我的基本设置... 家庭 hasMany Students hasMany Enrollment
如果注册为空,有没有办法排除学生?这是我的查找方法。
$options = array(
'order' => array('Family.family_last_name'),
'group' => 'Family.id',
'contain' => array(
'Student', 'Student.Enrollment'
),
'joins' => array(
array(
'table' => 'students',
'alias' => 'Student',
'type' => 'left',
'conditions' => array(
'Family.id = Student.family_id'
)
),
array(
'table' => 'enrollment',
'alias' => 'Enrollment',
'type' => 'left',
'conditions' => array(
'Enrollment.student_id = Student.id'
)
)
),
'conditions' => array(
'Enrollment.status =' => 'withdrawn'
)
);
$enrollment = $this->Family->find( 'all', $options);
这是它返回的数组。如何删除杰克?
[Student] => Array
(
[0] => Array
(
[id] => 92
[first_name] => Jack
[Enrollment] => Array
(
)
)
[1] => Array
(
[id] => 93
[first_name] => Jill
[Enrollment] => Array
(
[0] => Array
(
[id] => 99
[student_id] => 93
[grade] => 4
)
)
)
)