I have a classic ManyToMany on my entity. I would like to find Session by its disciplines.
class Session
/**
* @ORM\ManyToMany(targetEntity=Discipline::class)
*/
private $disciplines;
Example of my database:
Session Discipline
51 1
51 2
52 2
52 3
52 4
53 1
If I send
$disciplines = [1,2];
I would like the Session 51
If I send
$disciplines = [1];
I would like the Session 53
If I send
$disciplines = [2,3,4];
I would like the Session 52
I have this query
$queryBuilder
->innerJoin('s.disciplines', 'dis')
->andWhere($queryBuilder->expr()->in('dis.id', ':disciplines'))
->setParameter(':disciplines', $disciplines, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY)
;
But the request its not strict. How can I improve this?