Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. I have 3 models/tables: Instructors, Courses, InstructorCourses
  2.  
  3. InstructorCourses shows which instructors can teach a course (instructor_id and course_id). There can be many instructors for a given course.
  4.  
  5. I am trying to retrieve the courses an instructor can teach. So far, I have:
  6.  
  7. $courses = $this->Courses->find('all')
  8. ->where(['Courses.active' => 1])
  9. ->contain([
  10. 'InstructorCourses' => [
  11. 'conditions' => ['InstructorCourses.instructor_id' => $instructor_id],
  12. ]
  13. ])->order(['Courses.date_start ASC']);
  14.  
  15. 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