-1

I have 2 tables
student_job_log->id,job_id,student_id,created_dt
student_info->id,user_id,first_name,last_name

I have made the relations in model(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')),


        );
    }

I got the error in this what is the problem. something is wrong in my relations that i dont know :(

I want the first_name and last_name from student_info plz help me...:(

4

1 に答える 1

0

外部キーは、StudentInfo にマップされている現在のモデルのものでなければなりません

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

今のように使用します

echo $job->student_info->first_name . ', ' . $job->student_info->last_name;
于 2012-04-19T16:13:50.760 に答える