35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Temperature;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @method Temperature|null find($id, $lockMode = null, $lockVersion = null)
|
|
* @method Temperature|null findOneBy(array $criteria, array $orderBy = null)
|
|
* @method Temperature[] findAll()
|
|
* @method Temperature[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
*/
|
|
class TemperatureRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Temperature::class);
|
|
}
|
|
|
|
public function findByDateRange(\DateTime $fromDate, \DateTime $toDate)
|
|
{
|
|
return $this->createQueryBuilder('t')
|
|
->orderBy('t.date')
|
|
->andWhere('t.date >= :fromDate')
|
|
->andWhere('t.date <= :toDate')
|
|
->setParameter('fromDate', $fromDate->format('Y-m-d H:i:s'))
|
|
->setParameter('toDate', $toDate->format('Y-m-d H:i:s'))
|
|
->getQuery()
|
|
->getResult()
|
|
;
|
|
}
|
|
}
|