class EntryRepository extends EntityRepository
{
- /**
- * Return a query builder to used by other getBuilderFor* method.
- *
- * @param int $userId
- *
- * @return QueryBuilder
- */
- private function getBuilderByUser($userId)
- {
- return $this->createQueryBuilder('e')
- ->andWhere('e.user = :userId')->setParameter('userId', $userId)
- ->orderBy('e.createdAt', 'desc')
- ;
- }
-
/**
* Retrieves all entries for a user.
*
// We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive
$qb
- ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%'.$term.'%')
+ ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%' . $term . '%')
->leftJoin('e.tags', 't')
->groupBy('e.id');
}
if (null !== $isPublic) {
- $qb->andWhere('e.uid IS '.(true === $isPublic ? 'NOT' : '').' NULL');
+ $qb->andWhere('e.uid IS ' . (true === $isPublic ? 'NOT' : '') . ' NULL');
}
if ($since > 0) {
->where('e.user=:userId')->setParameter('userId', $userId)
;
- return $qb->getQuery()->getSingleScalarResult();
+ return (int) $qb->getQuery()->getSingleScalarResult();
}
/**
->andWhere('t.id=:tagId')->setParameter('tagId', $tagId)
;
- return $qb->getQuery()->getSingleScalarResult();
+ return (int) $qb->getQuery()->getSingleScalarResult();
}
/**
->getQuery()
->getResult();
}
+
+ /**
+ * Return a query builder to used by other getBuilderFor* method.
+ *
+ * @param int $userId
+ *
+ * @return QueryBuilder
+ */
+ private function getBuilderByUser($userId)
+ {
+ return $this->createQueryBuilder('e')
+ ->andWhere('e.user = :userId')->setParameter('userId', $userId)
+ ->orderBy('e.createdAt', 'desc')
+ ;
+ }
}