2020-03-16 14:19:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repository;
|
|
|
|
|
|
|
|
use App\Entity\Hygrometry;
|
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
|
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @method Hygrometry|null find($id, $lockMode = null, $lockVersion = null)
|
|
|
|
* @method Hygrometry|null findOneBy(array $criteria, array $orderBy = null)
|
|
|
|
* @method Hygrometry[] findAll()
|
|
|
|
* @method Hygrometry[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
|
|
*/
|
|
|
|
class HygrometryRepository extends ServiceEntityRepository
|
|
|
|
{
|
|
|
|
public function __construct(ManagerRegistry $registry)
|
|
|
|
{
|
|
|
|
parent::__construct($registry, Hygrometry::class);
|
|
|
|
}
|
|
|
|
|
2020-03-16 14:54:07 +01:00
|
|
|
public function findByDateRange(\DateTime $fromDate, \DateTime $toDate)
|
2020-03-16 14:19:25 +01:00
|
|
|
{
|
|
|
|
return $this->createQueryBuilder('h')
|
2020-03-16 14:54:07 +01:00
|
|
|
->orderBy('h.date')
|
|
|
|
->andWhere('h.date >= :fromDate')
|
|
|
|
->andWhere('h.date <= :toDate')
|
|
|
|
->setParameter('fromDate', $fromDate->format('Y-m-d H:i:s'))
|
|
|
|
->setParameter('toDate', $toDate->format('Y-m-d H:i:s'))
|
2020-03-16 14:19:25 +01:00
|
|
|
->getQuery()
|
|
|
|
->getResult()
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|