Category: dql

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; } }…

Doctrine: retrieving an ordered single entity from a one to many relationship

Suppose the following structure database structure – whereby a category has many articles, and an article has many comments: Category: – id Article: – id – category_id Comment: – id – created_at – article_id Using Doctrine, what is the best/standard…