1
votes

I have three tables such as A, B and C. There is ManyToMany relation from table A to table B. At the same time Table C stores the relations between table A and B.

I want a connection between the tables. For example i want to print a data in table A which relates with table B. It's ok but when i want to take it to the next level and print a data in table A which relates with table B and which relates in table C, it doesn't consider the second condition.

That's my problem.

For better understanding

A: Tv Shows B: Actors C: Roles

I want to display role of an actor who acts in a certain tv show. But it returns me all roles the actor has played before (Including other tv shows). But i want the result to turn me as just one role (just one tv show)

Tv Show (1st filter) > Actor (2nd filter) > Role (Result)

Problem: I can't apply 1st filter to results.

Thanks in advance.

1

1 Answers

0
votes

What you want to do is to allow the role table to act as the bridge between shows and actors.

Shows 1:many Roles many:1 Actors

So when you link Show and Actor you specify which role an actor plays for a given show. Drop the Doctrine 2 many to many relation between Show and Actor and replace with two 1:many relations with roles.

After that the queries will be easy.