As far as I can tell, assignments
are related to teachers
through subjects
, right? Then, on Subject
model:
public $belongsTo = array('Teacher');
Also, on AppModel
, use Containable
behavior:
public $actsAs = array('Containable');
Now, you can do a find on assignment
this way:
$this->Assignment->find('all', array(
'fields' => array('id', 'student_id')
'contain' => array(
'Subject' => array(
'fields' => array('id', 'subject_name')
'Teacher' => array(
'fields' => array('id', 'teacher_name')
)
)
)
));
Containable
behavior will let you do a deep search through related models