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

28 lines
666 B
PHP
Raw Normal View History

2015-06-23 09:38:43 +00:00
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity;
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()
;
}
}