64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Bible;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\ORM\EntityManager;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<Bible>
|
|
*
|
|
* @method Bible|null find($id, $lockMode = null, $lockVersion = null)
|
|
* @method Bible|null findOneBy(array $criteria, array $orderBy = null)
|
|
* @method Bible[] findAll()
|
|
* @method Bible[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
*/
|
|
class BibleRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Bible::class);
|
|
}
|
|
|
|
public function findRange(Bible $bible, array $passage): array
|
|
{
|
|
return $this->createQueryBuilder('b')
|
|
->andWhere('b.book = :book')
|
|
->andWhere('b.chapter = :chapter')
|
|
->andWhere('b.verse BETWEEN :verseStart AND :verseEnd')
|
|
->setParameter('book', $bible->getBook())
|
|
->setParameter('chapter', $bible->getChapter())
|
|
->setParameter('verseStart', $passage[0])
|
|
->setParameter('verseEnd', $passage[1])
|
|
->getQuery()
|
|
->getResult();
|
|
}
|
|
|
|
// /**
|
|
// * @return Bible[] Returns an array of Bible objects
|
|
// */
|
|
// public function findByExampleField($value): array
|
|
// {
|
|
// return $this->createQueryBuilder('b')
|
|
// ->andWhere('b.exampleField = :val')
|
|
// ->setParameter('val', $value)
|
|
// ->orderBy('b.id', 'ASC')
|
|
// ->setMaxResults(10)
|
|
// ->getQuery()
|
|
// ->getResult()
|
|
// ;
|
|
// }
|
|
|
|
// public function findOneBySomeField($value): ?Bible
|
|
// {
|
|
// return $this->createQueryBuilder('b')
|
|
// ->andWhere('b.exampleField = :val')
|
|
// ->setParameter('val', $value)
|
|
// ->getQuery()
|
|
// ->getOneOrNullResult()
|
|
// ;
|
|
// }
|
|
}
|