A
A
Alexander Sinitsyn2019-12-05 12:06:19
Yii
Alexander Sinitsyn, 2019-12-05 12:06:19

How to link three tables through two link tables?

There are such tables
versions (id)
groups (id)
items (id, group_id)
And tables of connection
version_groups (vesion_id, group_id)
version_items (versions_id, item_id)
The connection of groups with the version works, it returns by ->groups version groups

public function getGroups()
    {
    return $this->hasMany(Groups::className(), ['id' => 'group_id'])
            ->viaTable('version_groups', ['version_id' => 'id']);
    }

But ->items from the group, gives all the elements of the group.
How to add the version by which the group is selected to the link between the elements and the group?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question