createQueryBuilder('c'); $entityStr = $entity instanceof Person ? 'person' : 'household'; $qb->where("c.{$entityStr} = :{$entityStr}") // TODO: in controller, the budget and charges asked are also for future and actual //->andWhere('c.startDate < :date') // TODO: there is a misconception here, the end date must be lower or null. startDate are never null //->andWhere('c.startDate < :date OR c.startDate IS NULL'); ; if (null !== $sort) { $qb->orderBy($sort); } $qb->setParameters([ $entityStr => $entity, //'date' => $date, ]); return $qb->getQuery()->getResult(); } }