Joins can be done as follows , substitute your tables instead of mine
Suppose here my table , controller is CourseLessonsReference
Controller , so I can join other 2 or many tables as follows:
$conditionForId = array('CourseLessonsReference.course_id'=>$package_id,
);
//Pagination logic
$this->paginate = $allConditionsFields = array('conditions' => $conditionSearchLessonsByCourse,
"joins" => array(
array(//UserCourse = Course Join
"table" => "courses",
"alias" => "Course1",
"type" => "INNER",
"conditions" => array(
"Course1.id = CourseLessonsReference.course_id"
)
),//For Category = Course Join
array(
"table" => "course_categories",
"alias" => "CourseCategory",
"type" => "INNER",
"conditions" => array(
"CourseCategory.id = Course1.course_category_id"
)
)
),
'recursive' => 2
);
$resultOfJoin = $this->CourseLessonsReference->find('all', $allConditionsFields);
$resultOfJoin will give you result for Joins of 3 tables.
It means join Current table CourseLessonsReference
with specified tables in Join tag in $allConditionsFields array .
As you didnt provide schema of your tables , Here in my case , Current Controller/model/table is CourseLessonsReference which will have references. References are associated with Course so course_id is foreign key in course_lessons_reference table . So this is 1 join. Now Course is connected to Category so , course will have course_category_id
as foreign key.