Doctrine 2 getting a collection from 2 relationships?

Probably the best way to do this is to create a relationship from Followers to Members Then create a EntityRepository for the Comments Entity in which you'll create a function like: getCommentsByUserIdIncludingFollowers($userId) in which you create a DQL query that returns the correct information/comments you need This would be the way I'd suggest Kind Regards Robin.

Probably the best way to do this is to create a relationship from Followers to Members. Then create a EntityRepository for the Comments Entity in which you'll create a function like: getCommentsByUserIdIncludingFollowers($userId) in which you create a DQL query that returns the correct information/comments you need. This would be the way I'd suggest.

Kind Regards, Robin.

– dean jase Aug 10 at 12:06 In the Followers entity I would create a ManyToMany relationship to Members. You probably want to have One follower to be able to follow multiple Members and have one member to have multiple followers. See: doctrine-project.

Org/docs/orm/2.0/en/reference/… – AquaRobin Aug 10 at 19:42 but if I do that, it will created a manay-many table, which shows the links between members and followers. So, how will that work.. how would I then attach the comments to this linked table? – dean jase Aug 11 at 15:24 You would have a comment from a member, but can then do a query where you select all comments from the current logged in person, including his/her follower's comments by using JOIN's in the query.

Maybe you would also have to look into the many-to-many relation in Member itself. As it seems you want another member to be following other members.So a member would have the $following Many-To-Many and also the $followers Many-To-Many as reverse. – AquaRobin Aug 12 at 6:28.

So now, I can get an collection of all entries for any user. But I need to create anothewr table called 'followers' , where each user can follow each. Therefore, now, I want to be able to get all comments from 1 user also the comments for the users he is following too.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions