<?php
namespace App\Repository;
use App\Entity\IpaInforme;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<IpaInforme>
*
* @method IpaInforme|null find($id, $lockMode = null, $lockVersion = null)
* @method IpaInforme|null findOneBy(array $criteria, array $orderBy = null)
* @method IpaInforme[] findAll()
* @method IpaInforme[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class IpaInformeRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, IpaInforme::class);
}
public function add(IpaInforme $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(IpaInforme $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
/**
*
* @category function
*
* @return array Devuelve un array de resultados
*/
public function todos(): array
{
return $this->createQueryBuilder('p')
->select('p.fecha, p.nivel_del_embalse, p.caudal_vertido, p.caudal_turbinado, p.caudal_de_aportes')
->orderBy('p.fecha', 'DESC')
->getQuery()
->getResult()
;
}
/**
*
* @category function
*
* @return array Devuelve un array de resultados
*/
public function listExport($limit=365): array
{
return $this->createQueryBuilder('p')
->select('p.fecha, p.nivel_del_embalse, p.caudal_vertido, p.caudal_turbinado, p.caudal_de_aportes')
->orderBy('p.fecha', 'DESC')
->setMaxResults($limit)
->getQuery()
->getResult()
;
}
// /**
// * @return IpaInforme[] Returns an array of IpaInforme objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('i')
// ->andWhere('i.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('i.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?IpaInforme
// {
// return $this->createQueryBuilder('i')
// ->andWhere('i.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}