diff options
Diffstat (limited to 'src/WallabagBundle/Repository/EntriesRepository.php')
-rw-r--r-- | src/WallabagBundle/Repository/EntriesRepository.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/WallabagBundle/Repository/EntriesRepository.php b/src/WallabagBundle/Repository/EntriesRepository.php index c355a012..c4428a1d 100644 --- a/src/WallabagBundle/Repository/EntriesRepository.php +++ b/src/WallabagBundle/Repository/EntriesRepository.php | |||
@@ -4,31 +4,31 @@ namespace WallabagBundle\Repository; | |||
4 | 4 | ||
5 | use Doctrine\ORM\Query; | 5 | use Doctrine\ORM\Query; |
6 | use Doctrine\ORM\EntityRepository; | 6 | use Doctrine\ORM\EntityRepository; |
7 | use Doctrine\ORM\Tools\Pagination\Paginator; | ||
7 | 8 | ||
8 | /** | ||
9 | * EntriesRepository | ||
10 | * | ||
11 | * This class was generated by the Doctrine ORM. Add your own custom | ||
12 | * repository methods below. | ||
13 | */ | ||
14 | class EntriesRepository extends EntityRepository | 9 | class EntriesRepository extends EntityRepository |
15 | { | 10 | { |
16 | public function findUnreadByUser($userId) | 11 | public function findUnreadByUser($userId, $firstResult, $maxResults = 12) |
17 | { | 12 | { |
18 | $qb = $this->createQueryBuilder('e') | 13 | $qb = $this->createQueryBuilder('e') |
19 | ->select('e') | 14 | ->select('e') |
15 | ->setFirstResult($firstResult) | ||
16 | ->setMaxResults($maxResults) | ||
20 | ->where('e.isRead = 0') | 17 | ->where('e.isRead = 0') |
21 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 18 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
22 | ->getQuery() | 19 | ->getQuery(); |
23 | ->getResult(Query::HYDRATE_ARRAY); | ||
24 | 20 | ||
25 | return $qb; | 21 | $pag = new Paginator($qb); |
22 | |||
23 | return $pag; | ||
26 | } | 24 | } |
27 | 25 | ||
28 | public function findArchiveByUser($userId) | 26 | public function findArchiveByUser($userId, $firstResult, $maxResults = 12) |
29 | { | 27 | { |
30 | $qb = $this->createQueryBuilder('e') | 28 | $qb = $this->createQueryBuilder('e') |
31 | ->select('e') | 29 | ->select('e') |
30 | ->setFirstResult($firstResult) | ||
31 | ->setMaxResults($maxResults) | ||
32 | ->where('e.isRead = 1') | 32 | ->where('e.isRead = 1') |
33 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 33 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
34 | ->getQuery() | 34 | ->getQuery() |
@@ -37,10 +37,12 @@ class EntriesRepository extends EntityRepository | |||
37 | return $qb; | 37 | return $qb; |
38 | } | 38 | } |
39 | 39 | ||
40 | public function findStarredByUser($userId) | 40 | public function findStarredByUser($userId, $firstResult, $maxResults = 12) |
41 | { | 41 | { |
42 | $qb = $this->createQueryBuilder('e') | 42 | $qb = $this->createQueryBuilder('e') |
43 | ->select('e') | 43 | ->select('e') |
44 | ->setFirstResult($firstResult) | ||
45 | ->setMaxResults($maxResults) | ||
44 | ->where('e.isFav = 1') | 46 | ->where('e.isFav = 1') |
45 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 47 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
46 | ->getQuery() | 48 | ->getQuery() |