T
T
thatside2015-06-01 16:21:41
symfony
thatside, 2015-06-01 16:21:41

How to set filter for OneToMany relation in Symfony2?

You need to create a filter based on an array. That is, there is a one-to-many relationship, the relationship is established ("portfolio" - "portfolio-category"). At the input I have an array of ID categories, you need to get those values ​​in which the categories specified for the portfolio fully correspond to the array of categories.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Komarov, 2015-06-01
@maNULL

Possibly like this:

$array = []; // массив ваших id-шников
$this->em->getRepository('%repoName%')->findBy(['id'] => $array);

I did not encounter Symphony, but I use the doctrine

T
thatside, 2015-06-01
@thatside

I decided on a crutch: I added conditions to the WHERE to the queryBuilder in the loop and also set the parameters through setParameters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question