]>
Commit | Line | Data |
---|---|---|
9d50517c NL |
1 | <?php |
2 | ||
3 | namespace WallabagBundle\Repository; | |
4 | ||
5 | use Doctrine\ORM\Query; | |
6 | use Doctrine\ORM\EntityRepository; | |
163eae0b | 7 | use Doctrine\ORM\Tools\Pagination\Paginator; |
9d50517c | 8 | |
9d50517c NL |
9 | class EntriesRepository extends EntityRepository |
10 | { | |
163eae0b | 11 | public function findUnreadByUser($userId, $firstResult, $maxResults = 12) |
9d50517c NL |
12 | { |
13 | $qb = $this->createQueryBuilder('e') | |
14 | ->select('e') | |
163eae0b NL |
15 | ->setFirstResult($firstResult) |
16 | ->setMaxResults($maxResults) | |
9d50517c NL |
17 | ->where('e.isRead = 0') |
18 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | |
163eae0b | 19 | ->getQuery(); |
9d50517c | 20 | |
163eae0b NL |
21 | $pag = new Paginator($qb); |
22 | ||
23 | return $pag; | |
9d50517c | 24 | } |
bd9f0815 | 25 | |
163eae0b | 26 | public function findArchiveByUser($userId, $firstResult, $maxResults = 12) |
bd9f0815 NL |
27 | { |
28 | $qb = $this->createQueryBuilder('e') | |
29 | ->select('e') | |
163eae0b NL |
30 | ->setFirstResult($firstResult) |
31 | ->setMaxResults($maxResults) | |
bd9f0815 NL |
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 | ||
163eae0b | 40 | public function findStarredByUser($userId, $firstResult, $maxResults = 12) |
bd9f0815 NL |
41 | { |
42 | $qb = $this->createQueryBuilder('e') | |
43 | ->select('e') | |
163eae0b NL |
44 | ->setFirstResult($firstResult) |
45 | ->setMaxResults($maxResults) | |
bd9f0815 NL |
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 | } | |
9d50517c | 53 | } |