<?php
namespace App\Repository;
use App\Entity\NonHdlCholesterol;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method NonHdlCholesterol|null find($id, $lockMode = null, $lockVersion = null)
* @method NonHdlCholesterol|null findOneBy(array $criteria, array $orderBy = null)
* @method NonHdlCholesterol[] findAll()
* @method NonHdlCholesterol[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class NonHdlCholesterolRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, NonHdlCholesterol::class);
}
public function getByValue(int $cholesterol)
{
return $this->getEntityManager()->createQueryBuilder()
->select('hc')
->from(NonHdlCholesterol::class, 'hc')
->where('(:cholesterol BETWEEN hc.fromVal AND hc.toVal) OR (:cholesterol >= hc.fromVal AND hc.toVal IS NULL)')
->setParameter('cholesterol', $cholesterol)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
}