Here's my basic setup... Families hasMany Students hasMany Enrollment
Is there a way to exclude a student if enrollment is empty? Here is my find method.
$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);
Here is the array that it is returning. How can I remove Jack?
[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
)
)
)
)