I am using symfony2 for my app. I have two entities, Content and Albums with ManyToMany relationship. For example, one content may have many albums and vice versa.
$em->getRepository('MyAppBundle:Content')
->createQueryBuilder('c')
->select('c.id, c.title, c.sequence, c.sequence_count, c.category_sequence, c.unique_id, c.priority, c.status')
->addSelect('o.slug as owner')
->addSelect('cat.slug as category')
->addSelect('a.name as album')
->innerJoin('c.content_owner', 'o')
->innerJoin('c.category', 'cat')
->leftJoin('c.albums', 'a')
->getQuery()
->getArrayResult();
With this query I want to list all contents whether it has album or not, it works fine but if one content has two album the content print twice. How can I avoid the duplicate?
Thanks