user2326568
user2326568

Reputation: 355

get logged in user with joined data

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.

Upvotes: 1

Views: 75

Answers (1)

Frank B
Frank B

Reputation: 3697

Just write your custom query to load the user and add a JOIN

http://symfony.com/doc/current/cookbook/security/entity_provider.html#using-a-custom-query-to-load-the-user

Upvotes: 3

Related Questions