/ src / Repository / PlayerRepository.php
PlayerRepository.php
 1  <?php
 2  
 3  namespace App\Repository;
 4  
 5  use App\Entity\Player;
 6  use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
 7  use Doctrine\Persistence\ManagerRegistry;
 8  
 9  /**
10   * @extends ServiceEntityRepository<Player>
11   *
12   * @method Player|null find($id, $lockMode = null, $lockVersion = null)
13   * @method Player|null findOneBy(array $criteria, array $orderBy = null)
14   * @method Player[]    findAll()
15   * @method Player[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
16   */
17  class PlayerRepository extends ServiceEntityRepository
18  {
19      public function __construct(ManagerRegistry $registry)
20      {
21          parent::__construct($registry, Player::class);
22      }
23  
24      public function getTotalByCrc32server(
25          int $crc32server
26      ): int
27      {
28          return $this->createQueryBuilder('p')
29              ->select('count(p.id)')
30              ->where('p.crc32server = :crc32server')
31              ->setParameter('crc32server', $crc32server)
32              ->getQuery()
33              ->getSingleScalarResult()
34          ;
35      }
36  }