| Current Path : /var/www/v3.cesa.co.za/src/UserBundle/Repository/ |
| Current File : /var/www/v3.cesa.co.za/src/UserBundle/Repository/CCEStudentRepository.php |
<?php
namespace App\UserBundle\Repository;
use App\UserBundle\Entity\CCEStudent;
use App\UserBundle\Util\CCEStudentDisplayOrder;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<CCEStudent>
*
* @method CCEStudent|null find($id, $lockMode = null, $lockVersion = null)
* @method CCEStudent|null findOneBy(array $criteria, array $orderBy = null)
* @method CCEStudent[] findAll()
* @method CCEStudent[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CCEStudentRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, CCEStudent::class);
}
/**
* @param array<string, mixed> $criteria
* @return CCEStudent[]
*/
public function findByOrdered(array $criteria, ?int $limit = null, ?int $offset = null): array
{
$qb = $this->createQueryBuilder('s');
foreach ($criteria as $field => $value) {
$qb->andWhere('s.' . $field . ' = :' . $field)->setParameter($field, $value);
}
CCEStudentDisplayOrder::applyToQueryBuilder($qb, 's');
if ($limit !== null) {
$qb->setMaxResults($limit);
}
if ($offset !== null) {
$qb->setFirstResult($offset);
}
return $qb->getQuery()->getResult();
}
/**
* @return CCEStudent[]
*/
public function findAllOrdered(): array
{
$qb = $this->createQueryBuilder('s');
CCEStudentDisplayOrder::applyToQueryBuilder($qb, 's');
return $qb->getQuery()->getResult();
}
// /**
// * @return CCEStudent[] Returns an array of CCEStudent objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('c.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?CCEStudent
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}