I'm trying to find a way to get the current logged in user with additional data without running another query, for example lets say each user has one to many relation to messages, so if I run in controller $user = $this->getUser(); $userMessages = $user->getMessages(); I will have to run two queries, I'm looking for a way to force\change the getUser function to pre-load the data with join statement.
Asked
Active
Viewed 70 times
1
-
1`fetch="EAGER"` will still result in two queries as doctrine fetches entities, ref http://stackoverflow.com/questions/18159333/doctrine2-eager-loading-runs-multiple-queries-instead-of-1 – Rooneyl Nov 03 '15 at 13:34
1 Answers
3
Just write your custom query to load the user and add a JOIN

Frank B
- 3,667
- 1
- 16
- 22
-
Seems like the solution I was looking for, I'll check it up if working as expected I will flag as answer, thanks :) – user2326568 Nov 03 '15 at 13:42
-
That answer was correct, though after looking into it I got that my question was wrong, I need to use different joins to each Controller, I've tried to find in the documentation how to do so, though can't find it, if you can help me with that it would be great, thanks. – user2326568 Nov 03 '15 at 13:58