JOIN DQL SYMFONY

i want to count how many baby for a parent

 class abonnementRepository extends DoctrineORMEntityRepository
{
    public function SumEnfantDQL($id)
    {
        $entityManager = $this->getEntityManager();
        $query = $entityManager->createQueryBuilder();
        $query->select('sum(o.id) AS somme');
        $query->from('AppBundle:enfant', 'o');
        $query->join('AppBundle:User','p')->where('p.id = :id');
        $rez = $query->getQuery()->getResult();
        return $rez;
    }
}

the entity enfant had matricul_prt and entity user had enfant_id and $id parameter is the parent id
i don’t know how it work with join or innerJoin .So what i want to do is

SELECT SUM(*)
FROM enfant e
WHERE e.matricul_prt = $id; 

Thank you so much

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *