/**
  * Retorna o itens da paginação
  *
  * @param int $iInicioPaginacao
  * @param int $iItensPorPagina
  * @return array
  */
 public function getItems($iInicioPaginacao, $iItensPorPagina)
 {
     $this->_query->setFirstResult($iInicioPaginacao);
     $this->_query->setMaxResults($iItensPorPagina);
     $aResultado = $this->_query->getQuery()->getResult();
     $aRetorno = array();
     foreach ($aResultado as $sModelo) {
         $aRetorno[] = new $this->_modelName($sModelo);
     }
     return $aRetorno;
 }
 public function getItems($offset, $itemCountPerPage)
 {
     $this->_query->setFirstResult($offset);
     $this->_query->setMaxResults($itemCountPerPage);
     $a = $this->_query->getQuery()->getResult();
     $r = array();
     foreach ($a as $i) {
         $r[] = new $this->_modelName($i);
     }
     return $r;
 }
Пример #3
0
 /**
  * Returns the whole aggregated feed. You can limit the list giving any number.
  *
  * @return List<UnifiedSocialEntityInterface>
  */
 public function getFeed($limit = false)
 {
     if ($limit !== false && is_int($limit)) {
         $this->qb->setMaxResults($limit);
     }
     $this->qb->andWhere('e.approved = 1');
     return $this->qb->getQuery()->getResult();
 }
Пример #4
0
 /**
  * Returns items matching the given criteria
  *
  * @param  int $offset Page offset
  * @param  int $itemCountPerPage Number of items per page
  * @return array
  */
 public function getItems($offset, $itemCountPerPage)
 {
     if ($offset > 0) {
         $this->query->setFirstResult($offset);
     }
     $this->query->setMaxResults($itemCountPerPage);
     return $this->query->select('e')->getQuery()->getResult();
 }
Пример #5
0
 /**
  * Set the page with paginate attribute.
  *
  * @param int $page
  * @param int $limit
  *
  * @return $this
  */
 public function paginate($limit = 25, $page = 0)
 {
     if ($limit > 0) {
         $this->queryBuilder->setMaxResults($limit);
     }
     if ($page > 0) {
         $this->queryBuilder->setFirstResult($page * $limit);
     }
     return $this;
 }
Пример #6
0
 /**
  * Returns the whole aggregated feed. You can limit the list giving any number.
  *
  * @param bool  $onlyApproved if only approved elements should be returned. default is true.
  * @param int   $limit        how many items should be fetched at maximum
  * @param array $requestIds   which requestIds should be fetched, if left empty all are fetched
  * @return array<TwitterEntityInterface> List of twitter entities
  */
 public function getFeed($onlyApproved = true, $limit = false, array $requestIds = array())
 {
     $result = array();
     foreach ($this->apiRequests as $request) {
         if (count($requestIds) > 0 && !in_array($request->getId(), $requestIds)) {
             continue;
         }
         $this->initializeQueryBuilder($request->getId());
         if ($limit !== false && is_int($limit)) {
             $this->qb->setMaxResults($limit);
         }
         if ($onlyApproved) {
             $this->qb->andWhere('e.approved = true');
         }
         $this->qb->andWhere('e.requestId = :requestId')->setParameter('requestId', $request->getId());
         $result = array_merge($result, $this->qb->getQuery()->getResult());
     }
     return $result;
 }
Пример #7
0
 public function getListWishedBooks($userId, $limit, $useCache)
 {
     $cacheId = $this->getCacheId(__FUNCTION__, array($userId));
     $queryBuilder = new \Doctrine\ORM\QueryBuilder($this->entityManager);
     $queryBuilder->select("ub, u, b, r, p, c")->from(self::MODEL, "ub")->join("ub.user", "u")->join("ub.book", "b")->leftJoin("ub.reading_state", "r")->leftJoin("b.publisher", "p")->leftJoin("b.contributors", "c")->orderBy("ub.id", "DESC")->where("u.id = :id")->andWhere("ub.is_deleted = 0")->andWhere("ub.is_wished = 1")->setParameter("id", $userId);
     if ($limit != -1) {
         $queryBuilder->setMaxResults($limit);
     }
     $result = $this->getResults($queryBuilder->getQuery(), $cacheId, $useCache);
     return $result;
 }