Data od do w doctrine

public function getUniqueTransactionCountByStatusInDateRange(\DateTime $dateFrom, \DateTime $dateTo, $transactionStatus) {
        $query = $this->getEntityManager()->createQueryBuilder()
                        ->from(Transaction::class, 't')
                        ->select('COUNT(DISTINCT(t.transaction_id))')
                        ->where('t.created_at >= :DateTimeBegin')->setParameter('DateTimeBegin', $dateFrom->format('Y-m-d H:i:s'))
                        ->andWhere('t.created_at <= :DateTimeEnd')->setParameter('DateTimeEnd', $dateTo->format('Y-m-d H:i:s'))
                        ->andWhere('t.status = :Status')->setParameter('Status', $transactionStatus)
        ;

        try {
            return (int) $query->getQuery()->getSingleScalarResult();
        } catch (\Doctrine\ORM\NoResultException $e) {
            return 0;
        }
    }
Komentarze wyłączone