I have a database with Classes
, Semesters
, Users
, and Visits
(Visits
is a join table for Users
and Classes
)
The relations are:
User
hasAndBelongsToMany Class
(through Visits
Class
belongsTo Semester
Now I want to view all Visits
with Classes
in an active Semester
(The Semester
table has a field is_active
)
I read about a contain option for the find method and tried something like this:
$option = array(
"contain" => array(
"Class" => array(
"Semester" => array(
"conditions" => array("Semester.is_active" => true)
)
),
),
"conditions" => array(
"Visit.user_id" => $id,
)
);
But with this, classes in a not active semester are found, only the semester isn't.
Is something wrong with this? Or is there an other way?