Yii框架:条件的模型关系

时间:2014-02-02 06:54:54

标签: activerecord yii model relational database-relations

我有一个用户,个人资料,教师和学生模型。数据库如下所示:

enter image description here

relationsTeacher型号的Student功能中,我希望:

'profile' => array(self::HAS_ONE, 'Profile', 'user_id', 'condition' => 'profile.user_id = 'teacher.user_id'),

基本上,我想写一些与以下SQL查询输出相同结果的东西:

SELECT * FROM teacher, profile WHERE teacher.user_id = profile.user_id

SELECT * FROM student, profile WHERE student.user_id = profile.user_id

0 个答案:

没有答案