createQueryBuilder('e') ; if(isset($params['user'])) { $query->andWhere('e.user = :user')->setParameter('user', $params['user']) ; } if(isset($params['visitor'])) { $query->andWhere('e.visitor = :visitor')->setParameter('visitor', $params['visitor']) ; } $query->leftJoin('e.orderStatusHistories', 'orderStatusHistories') ->andWhere('SIZE(e.orderStatusHistories) = 0') ; return $query->getQuery()->getOneOrNullResult() ; } public function findAllByDateStartEnd($dateStart, $dateEnd) { $query = $this->findByMerchantQuery() ->andWhere('e.createdAt >= :dateStart') ->setParameter('dateStart', $dateStart) ->andWhere('e.createdAt <= :dateEnd') ->setParameter('dateEnd', $dateEnd) ; $query->leftJoin('e.orderStatusHistories', 'orderStatusHistories') ->andWhere('SIZE(e.orderStatusHistories) > 0') ; return $query->getQuery()->getResult() ; } }