Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I have 3 models/tables: Instructors, Courses, InstructorCourses
- InstructorCourses shows which instructors can teach a course (instructor_id and course_id). There can be many instructors for a given course.
- I am trying to retrieve the courses an instructor can teach. So far, I have:
- $courses = $this->Courses->find('all')
- ->where(['Courses.active' => 1])
- ->contain([
- 'InstructorCourses' => [
- 'conditions' => ['InstructorCourses.instructor_id' => $instructor_id],
- ]
- ])->order(['Courses.date_start ASC']);
- But this is returning all courses. What is the best way to go about this?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement