Is it possible to customize the SQL used for fetching relationship fields?
User U1 has friends U2 and U3,. This automatically means users U2 and U3 are friends with U1, as this is a reflexive relationship. The join table looks like this: (userId1, userId2, date). The catch here is that I don't want two different rows for every relation in the join table, but still be able to have a list of friends in the user entity. To make this happen, I need the order in which the IDs appear in the join table irrelevant.
That why I'm asking if I can modify the SQL used for fetching the relationship fields - I could make it look for the current user's id in both the first and the second column in the join table when populating the list of his friends.
I hope I was clear enough... Any thoughts on this? I could really use an advice...
Thanks a lot!
posted 7 years ago
how about just selecting both variants and merge them using UNION?
Of course you would have to add some criteria..
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads