createQueryBuilder('p') ->select('COUNT (p.id)') ->where('p.id = :person_id') ->setParameter(':person_id', $person_id) ->getQuery() ->getSingleScalarResult(); } /** * Return paginated participations for a person and in reachables circles. */ public function findByPersonInCircle($person_id, $reachablesCircles, $first, $max) { return $this->createQueryBuilder('p') ->join('p.event', 'e') ->where('p.person = :person_id') ->andWhere('e.circle IN (:reachable_circles)') ->orderBy('e.date', 'ASC') ->setParameters([ ':person_id' => $person_id, ':reachable_circles' => $reachablesCircles, ]) ->setFirstResult($first) ->setMaxResults($max) ->getQuery() ->getResult(); } }