]> git.immae.eu Git - github/wallabag/wallabag.git/blame_incremental - src/WallabagBundle/Repository/EntriesRepository.php
toggle archive / fav actions
[github/wallabag/wallabag.git] / src / WallabagBundle / Repository / EntriesRepository.php
... / ...
CommitLineData
1<?php
2
3namespace WallabagBundle\Repository;
4
5use Doctrine\ORM\Query;
6use Doctrine\ORM\EntityRepository;
7use Doctrine\ORM\Tools\Pagination\Paginator;
8
9class EntriesRepository extends EntityRepository
10{
11 public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
12 {
13 $qb = $this->createQueryBuilder('e')
14 ->select('e')
15 ->setFirstResult($firstResult)
16 ->setMaxResults($maxResults)
17 ->where('e.isRead = 0')
18 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
19 ->getQuery();
20
21 $pag = new Paginator($qb);
22
23 return $pag;
24 }
25
26 public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
27 {
28 $qb = $this->createQueryBuilder('e')
29 ->select('e')
30 ->setFirstResult($firstResult)
31 ->setMaxResults($maxResults)
32 ->where('e.isRead = 1')
33 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
34 ->getQuery()
35 ->getResult(Query::HYDRATE_ARRAY);
36
37 return $qb;
38 }
39
40 public function findStarredByUser($userId, $firstResult, $maxResults = 12)
41 {
42 $qb = $this->createQueryBuilder('e')
43 ->select('e')
44 ->setFirstResult($firstResult)
45 ->setMaxResults($maxResults)
46 ->where('e.isFav = 1')
47 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
48 ->getQuery()
49 ->getResult(Query::HYDRATE_ARRAY);
50
51 return $qb;
52 }
53}