// 1. select * from users where id = 1
$user = User::create()->find(1);
// 2. select * from user_groups where user_id = 1
$first_group = $user->groups->first();
// 3. select * from users where id = 1
echo $first_group->user->id;
The SQL statement in 3. is not necessary. When creating the user's collection of groups, each group should have it's spawned/reverse relationship identified and cached up.
Take this crude example where:
The SQL statement in 3. is not necessary. When creating the user's collection of groups, each group should have it's spawned/reverse relationship identified and cached up.