/**
* Fetch an entry with a tag. Only used for tests.
*
+ * @param int $userId
+ *
* @return Entry
*/
public function findOneWithTags($userId)
->getQuery()
->getResult();
- if (count($res) > 1) {
- return next($res);
+ if (count($res)) {
+ return current($res);
}
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();
+ }
}