Answer the question
In order to leave comments, you need to log in
How to implement linking Yii tables not by primary key?
I have two tables No. 1 ObjectSchedule and No. 2 ObjectScheduleDate, the relationship between them
I want to get the id_schedule associated with it in No. 2, which is not the primary key, by id in No. 1.
I write the following code in the model for #1 ObjectSchedule:
return array(
'scheduleDates' => array(self::BELONGS_TO, 'ObjectScheduleDate', 'id')
);
return array(
'scheduleDatesId' => array(self::HAS_ONE, 'ObjectSchedule', 'id_schedule'),
);
return array(
'scheduleDates' => array(self::BELONGS_TO, 'ObjectScheduleDate', array('id' => 'id_schedule'))
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question