]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/EntryRepository.php
Quickstart for beginners
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntryRepository.php
index c6763a40caa26d81febc8083bb4c4c267f94acf3..a16be9e01924d4cefb89b6a37db999fb341ef704 100644 (file)
@@ -122,6 +122,8 @@ class EntryRepository extends EntityRepository
     /**
      * Fetch an entry with a tag. Only used for tests.
      *
+     * @param int $userId
+     *
      * @return Entry
      */
     public function findOneWithTags($userId)
@@ -248,4 +250,21 @@ class EntryRepository extends EntityRepository
 
         return false;
     }
+
+    /**
+     * Count all entries for a user.
+     *
+     * @param int $userId
+     *
+     * @return integer
+     */
+    public function countAllEntriesByUsername($userId)
+    {
+        $qb = $this->createQueryBuilder('e')
+            ->select('count(e)')
+            ->where('e.user=:userId')->setParameter('userId', $userId)
+        ;
+
+        return $qb->getQuery()->getSingleScalarResult();
+    }
 }