I'm new to cakePHP and I'm having issues getting all of my models to link up correctly.
This is the layout of my models in cakePHP:
Class belongsTo Location
Class belongsTo ClassType
Class hasMany ScheduledClass
ScheduledClass belongsTo Instructor
My problem is that when I use:
$this->Class->find('all')
I only get data from the Class, Location, ClassType and ScheduledClass models. I do not get any data from the Instructor model.
I can set the recursive value to '2' and retreive the data from the Instructor model, but this results in a giant amount of queries(one for every row) instead of a join on "ScheduledClass.instructor_id = Instructor.id".
What I was hoping to acheive is something like:
SELECT
...
...
FROM classes as Class
INNER JOIN locations as Location on Class.location_id = Location.id
INNER JOIN class_types as ClassType on Class.class_type_id = ClassType.id
INNER JOIN scheduled_classes as ScheduledClass on ScheduledClass.class_id = Class.id
INNER JOIN instructors as Instructor on ScheduledClass.instructor_id = Instructor.id
I've tried using both Containable and Joins in order to get the right data, but I wasn't able to get either to work(possibly due to my misunderstanding their uses).
Thank you in advance!