How to create a LEFT JOIN with a SELECT subquery using QueryBuilder in Doctrine 2?

I need to limit the results of the LEFT JOIN, so I have to use a subquery. Can someone give me some advice on how I can do this with Doctrine 2?

Now I have:

  $qb = $this->_em->createQueryBuilder();
    return $qb->add('select', 'c,j')
             ->add('from', 'JobeetBundle:Category c')
             ->leftJoin('c.jobs', 'j', 'WITH', 'j.category = c')
             ->add('where', 'j.expiresAt > ?1')
             ->add('orderBy','j.expiresAt DESC')
             ->setParameter(1, new \DateTime())
             ->getQuery()
             ->getResult();

but I have to change it to limit the results of assignments to 10 for each category.

+5
source share
1 answer
+1
source

All Articles