2012-04-19 74 views
-1

加入我有2个表
student_job_log - > ID,JOB_ID,student_id数据,created_dt
student_info - > ID,USER_ID,名字,姓氏
留在警予

我已在关系模型(studentJobLog)

public function relations() 
    { 
     // NOTE: you may need to adjust the relation name and the related 
     // class name for the relations automatically generated below. 
     return array(
     'student_info'=>array(self::BELONGS_TO,'StudentInfo','id','joinType'=>'LEFT JOIN', 
            'select'=>'first_name, last_name')), 


     ); 
    } 

我得到的错误在这 是什么问题。 事情是错误的,我的关系,我不知道:(

我想从student_info PLZ的FIRST_NAME和LAST_NAME帮我... :(

+4

什么错误?我们应该猜到的? – Jon 2012-04-19 10:11:58

+0

你好@乔恩请给我查询(重lations)...我想从student_info表中创建first_name和last_name,并从student_job_log中创建created_dt – User1988 2012-04-19 10:16:05

+2

我不能那样做。如果你有一个具有充分记录的特定问题,我可以提供帮助。 – Jon 2012-04-19 10:18:09

回答

0

外键必须从你所映射的一个电流模式到StudentInfo

return array(
    'student_info'=>array(self::BELONGS_TO,'StudentInfo','student_id',), 
    ); 

现在使用它像

echo $job->student_info->first_name . ', ' . $job->student_info->last_name;