| Current Path : /var/www/v3.cesa.co.za/src/EventBundle/Repository/ |
| Current File : /var/www/v3.cesa.co.za/src/EventBundle/Repository/SchoolAttendeeRepository.php |
<?php
namespace App\EventBundle\Repository;
use App\EventBundle\Entity\SchoolAttendee;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<SchoolAttendee>
*
* @method SchoolAttendee|null find($id, $lockMode = null, $lockVersion = null)
* @method SchoolAttendee|null findOneBy(array $criteria, array $orderBy = null)
* @method SchoolAttendee[] findAll()
* @method SchoolAttendee[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SchoolAttendeeRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, SchoolAttendee::class);
}
/**
* Get the list of IDs
* @return array
*/
public function findAllIds()
{
return $this->createQueryBuilder('sa')
->select('sa.id')
->where('sa.cancelled = 0 OR sa.cancelled IS NULL')
// ->andWhere('sa.id = 38508')
// ->setMaxResults(100)
->getQuery()->getArrayResult()
;
}
/**
* Find school attendees by event ID and with attendee ID greater than specified value
*
* @param int $eventId The event ID
* @param int $lastAttendeeId The last attendee ID to filter from
* @return SchoolAttendee[]
*/
public function findByEventIdAndAttendeeIdGreaterThan(int $eventId, int $lastAttendeeId = 0): array
{
$queryBuilder = $this->createQueryBuilder('sa')
->andWhere('sa.school_event = :eventId')
->setParameter('eventId', $eventId);
if ($lastAttendeeId > 0) {
$queryBuilder->andWhere('sa.id > :lastAttendeeId');
$queryBuilder->setParameter('lastAttendeeId', $lastAttendeeId);
}
return $queryBuilder->orderBy('sa.id', 'ASC')
->getQuery()
->getResult();;
}
// /**
// * @return SchoolAttendee[] Returns an array of SchoolAttendee objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('s')
// ->andWhere('s.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('s.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?SchoolAttendee
// {
// return $this->createQueryBuilder('s')
// ->andWhere('s.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}