I have a User, Profile, Teacher, and Student models. Database looks as follows:
In the relations
function of my Teacher
and Student
models, I would like to have:
'profile' => array(self::HAS_ONE, 'Profile', 'user_id', 'condition' => 'profile.user_id = 'teacher.user_id'),
Basically, I would like to write something that would output the same result as the following SQL query:
SELECT * FROM teacher, profile WHERE teacher.user_id = profile.user_id
and
SELECT * FROM student, profile WHERE student.user_id = profile.user_id