point-tools/src/Skobkin/Bundle/PointToolsBundle/Repository/SubscriptionRepository.php

28 lines
670 B
PHP
Raw Normal View History

2015-06-23 09:38:43 +00:00
<?php
namespace Skobkin\Bundle\PointToolsBundle\Repository;
2015-06-23 09:38:43 +00:00
use Doctrine\ORM\EntityRepository;
class SubscriptionRepository extends EntityRepository
{
/**
* @param integer $id
* @return integer
*/
public function getUserSubscribersCountById($id)
{
2015-06-23 10:34:53 +00:00
if (!is_int($id)) {
throw new \InvalidArgumentException('$id must be an integer');
}
2015-06-23 09:38:43 +00:00
$qb = $this->createQueryBuilder('s');
return $qb
->select('COUNT(s)')
->innerJoin('s.author', 'a')
->where('a.id = :id')
->setParameter('id', $id)
->getQuery()->getSingleScalarResult()
;
}
}