30 lines
706 B
PHP
30 lines
706 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Magnetico\Repository;
|
|
|
|
use App\Magnetico\Entity\Torrent;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
class TorrentRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Torrent::class);
|
|
}
|
|
|
|
public function getTorrentsTotalCount(): int
|
|
{
|
|
$qb = $this->createQueryBuilder('t')
|
|
->select('COUNT(t.id)')
|
|
;
|
|
|
|
try {
|
|
return (int) $qb->getQuery()->getSingleScalarResult();
|
|
} catch (\Exception $ex) {
|
|
return 0;
|
|
}
|
|
}
|
|
}
|