X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FCoreBundle%2FRepository%2FEntryRepository.php;h=cd2b47b9f7c32b737d35910effe1cf53398adac8;hb=bccf7a70bc22171904a5bb82d282e9c956684abc;hp=75127b7d9e69d5ec1cf5d5f815e439c2d3ba559c;hpb=ab809de18415a9ce3bbc95d3a0a1af6c50a41c4f;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 75127b7d..cd2b47b9 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -309,4 +309,24 @@ class EntryRepository extends EntityRepository return $qb->getQuery()->getSingleScalarResult(); } + + /** + * Count all entries for a tag and a user. + * + * @param int $userId + * @param int $tagId + * + * @return int + */ + public function countAllEntriesByUserIdAndTagId($userId, $tagId) + { + $qb = $this->createQueryBuilder('e') + ->select('count(e.id)') + ->leftJoin('e.tags', 't') + ->where('e.user=:userId')->setParameter('userId', $userId) + ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId) + ; + + return $qb->getQuery()->getSingleScalarResult(); + } }