2015-06-23 09:38:43 +00:00
|
|
|
<?php
|
|
|
|
|
2016-03-23 16:59:06 +00:00
|
|
|
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()
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|