Answer the question
In order to leave comments, you need to log in
How to build a relation in yii 1.x not by pk?
There are two tables:
Specifications
id, key, name, category, lang
SpecificationsCategories
id, key, name, lang
The categories model is written like this:
public function relations()
{
return [
'specification'=>[self::HAS_MANY, 'Specifications', 'category',
'on'=>'t.lang = specification.lang',
'joinType' => 'inner join',
],
];
}
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