wallabag/src/WallabagBundle/Repository/EntriesRepository.php

54 lines
1.5 KiB
PHP
Raw Normal View History

2015-01-22 16:18:56 +00:00
<?php
namespace WallabagBundle\Repository;
use Doctrine\ORM\Query;
use Doctrine\ORM\EntityRepository;
2015-01-23 11:45:24 +00:00
use Doctrine\ORM\Tools\Pagination\Paginator;
2015-01-22 16:18:56 +00:00
class EntriesRepository extends EntityRepository
{
2015-01-23 11:45:24 +00:00
public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
2015-01-22 16:18:56 +00:00
{
$qb = $this->createQueryBuilder('e')
->select('e')
2015-01-23 11:45:24 +00:00
->setFirstResult($firstResult)
->setMaxResults($maxResults)
2015-01-22 16:18:56 +00:00
->where('e.isRead = 0')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
2015-01-23 11:45:24 +00:00
->getQuery();
2015-01-22 16:18:56 +00:00
2015-01-23 11:45:24 +00:00
$pag = new Paginator($qb);
return $pag;
2015-01-22 16:18:56 +00:00
}
2015-01-22 20:11:22 +00:00
2015-01-23 11:45:24 +00:00
public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
2015-01-22 20:11:22 +00:00
{
$qb = $this->createQueryBuilder('e')
->select('e')
2015-01-23 11:45:24 +00:00
->setFirstResult($firstResult)
->setMaxResults($maxResults)
2015-01-22 20:11:22 +00:00
->where('e.isRead = 1')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->getQuery()
->getResult(Query::HYDRATE_ARRAY);
return $qb;
}
2015-01-23 11:45:24 +00:00
public function findStarredByUser($userId, $firstResult, $maxResults = 12)
2015-01-22 20:11:22 +00:00
{
$qb = $this->createQueryBuilder('e')
->select('e')
2015-01-23 11:45:24 +00:00
->setFirstResult($firstResult)
->setMaxResults($maxResults)
2015-01-22 20:11:22 +00:00
->where('e.isFav = 1')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->getQuery()
->getResult(Query::HYDRATE_ARRAY);
return $qb;
}
2015-01-22 16:18:56 +00:00
}