Answer the question
In order to leave comments, you need to log in
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']);
}
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