Query builder join on ManyToMany relationship
Something like:
$this->createQueryBuilder()
->select('s')
->from('SuperCategory', 's')
->innerJoin('s.Category c ON c.category_id = s.superCategory_id')
->where('s.name = :superCategoryName')
->setParameter('superCategoryName', $superCategoryName)
->getQuery()
->getResult();
Got it :
public function findBySuperCategoryName($superCategoryName)
{
return $this->createQueryBuilder('c')
->innerJoin('c.superCategories', 's', 'WITH', 's.name = :superCategoryName')
->setParameter('superCategoryName', $superCategoryName);
}
The problem was that I had to ask for c.superCategories and not c.superCategory !