em->createQuery( "SELECT auction FROM \\Auction\\Entity\\Auction auction " . "WHERE auction.endDate LIKE :endDate AND auction.jobState = :status" ) ->setParameter('endDate', $jobRecord->openDate->format('Y-m-d') . '%') ->setParameter('status', 'Active') ->getArrayResult(); if (0 < count($items)) { throw new \Exception('There are auctions ending on this date, please remove auction items before deleting.'); } } }