php - How can I access pivot table attributes in doctrine without having entity for it

716

I have a many to many relationship between Location and Areas. So there are three tables location, areas and location_area(the pivot table). Now as we know on the pivot table I only have foreign keys from both table. So doctrine won't allow an entity for it as it requires primary key for an entity and logically the two foreign keys form a surrogate key. I don't want to add an extra column id to the table.

I have areas many to many relationship on the location table. So this is the query that I have wrote.

$query->leftJoin('q.areas', 'a');

And I need the location_areas table attribute for some condition. when I tried to access its attribute via the join that I have made above. Since it is a join with the many to many relationship areas so I assume it should return the pivot table attributes as well but it never does, What should I do in this situation.

Any help will be appreciated.

People are also looking for solutions to the problem: datetime - how to use epoch time in php by adding time offset value

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.