src/Repository/NonHdlCholesterolRepository.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\NonHdlCholesterol;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. /**
  7.  * @method NonHdlCholesterol|null find($id, $lockMode = null, $lockVersion = null)
  8.  * @method NonHdlCholesterol|null findOneBy(array $criteria, array $orderBy = null)
  9.  * @method NonHdlCholesterol[]    findAll()
  10.  * @method NonHdlCholesterol[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11.  */
  12. class NonHdlCholesterolRepository extends ServiceEntityRepository
  13. {
  14.     public function __construct(ManagerRegistry $registry)
  15.     {
  16.         parent::__construct($registryNonHdlCholesterol::class);
  17.     }
  18.     public function getByValue(int $cholesterol)
  19.     {
  20.         return $this->getEntityManager()->createQueryBuilder()
  21.             ->select('hc')
  22.             ->from(NonHdlCholesterol::class, 'hc')
  23.             ->where('(:cholesterol BETWEEN hc.fromVal AND hc.toVal) OR (:cholesterol >= hc.fromVal AND hc.toVal IS NULL)')
  24.             ->setParameter('cholesterol'$cholesterol)
  25.             ->setMaxResults(1)
  26.             ->getQuery()
  27.             ->getOneOrNullResult();
  28.     }
  29. }