opened
gadelkareem
username_0
I am trying to get results similar to Yii1 while using 'together' in the relations.
Here is an example:
```php
$user = User::find()->joinWith(['role'])->one();
echo $user->role->name;
```

On mysql log I see:
```
140806 12:53:29	   59 Connect	root@localhost on testDB
		   59 Query	SET NAMES 'utf8'
		   59 Query	SELECT `user`.* FROM `user` LEFT JOIN `role` ON `user`.`role_id` = `role`.`id`
		   59 Query	SHOW FULL COLUMNS FROM `user`
		   59 Query	SHOW CREATE TABLE `user`
		   59 Query	SELECT * FROM `role` WHERE `id`='2'
		   59 Query	SHOW FULL COLUMNS FROM `role`
		   59 Query	SHOW CREATE TABLE `role`
		   59 Quit
```

I think joinwith() fails to populate the relation after using JOIN?
Duplicated Queries While Using Joinwith
issue
created
ljames604
username_1
I Agree with username_0. This is a very unfortunate liability of using Yii2. Making 80% unnecessary database calls it totally unacceptable. This would only suffice for the simplest of database models. Any application that requires many table joins would severely suffer from this design flaw. Any application who uses a remote or external database connection, which is very common on apps hosted in the cloud, would suffer greatly as well. 

This would make an EAV database model totally out of the question. I have yet to encounter another framework that does not allow this functionality. The performance boost greatly outweighs the complexity.
comment
created
klimov-paul
username_2
You may use following extension to get rid of redundant queries:
https://github.com/yii2tech/ar-eagerjoin
comment