/**
* Fetch an entry with a tag. Only used for tests.
*
+ * @param int $userId
+ *
* @return Entry
*/
public function findOneWithTags($userId)
*
* @return array|bool
*/
- public function existByUrlAndUserId($url, $userId)
+ public function findByUrlAndUserId($url, $userId)
{
$res = $this->createQueryBuilder('e')
- ->select('e.id, e.createdAt')
->where('e.url = :url')->setParameter('url', $url)
->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
->getQuery()
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();
+ }
}