I
I
Ilya Plotnikov2015-02-17 20:15:33
MySQL
Ilya Plotnikov, 2015-02-17 20:15:33

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',
            ],
        ];
    }

But the bundle goes t.id = specification.category. I did not find a parameter with which you can specify the key.
How to explain to Yii that I need to bind like t.key = specification.category?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pantsarny, 2015-02-19
@ilyaplot

third parameter in relation array ['id' => 'category']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question