For these three tables, Table XXX has two column composite PK:
Table XXX:
- XXX_id_1
- XXX_id_2
- name
Table YYY:
- YYY_id
- name
Table XXX_has_YYY:
- X_id
- Y_id
- A_id
How can I define this relation in Yii’s ORM?
public function relations() {
return array(
'YYY' => array(self::MANY_MANY, 'YYY',
'XXX_has_YYY(XXX_id_1, XXX_id_2, YYY_id)'),
);
}
Please read the documentation.
Also, the second argument refers to the name of the active record class that the related object is of.
Your relation therefore should look something like this: