当前位置: 首页>>代码示例>>PHP>>正文


PHP Paginator::getQuery方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Tools\Pagination\Paginator::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::getQuery方法的具体用法?PHP Paginator::getQuery怎么用?PHP Paginator::getQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Tools\Pagination\Paginator的用法示例。


在下文中一共展示了Paginator::getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getIterator

 /**
  * Required by interface IteratorAggregate.
  *
  * {@inheritdoc}
  */
 public function getIterator()
 {
     $query = $this->paginator->getQuery();
     $query->setFirstResult(null);
     $query->setMaxResults(null);
     return $this->paginator;
 }
开发者ID:brick,项目名称:brick,代码行数:12,代码来源:QueryCollection.php

示例2: __construct

 /**
  * @param Query|QueryBuilder $query
  * @param int $limit
  * @param int $currentPage
  */
 public function __construct($query, $limit, $currentPage = 1)
 {
     $this->paginator = new DoctrinePaginator($query);
     $this->totalCount = $this->paginator->count();
     $this->limit = $limit;
     $this->pagesCount = (int) ceil($this->totalCount / $this->limit);
     if ($this->pagesCount > 0 && $currentPage > $this->pagesCount) {
         $currentPage = $this->pagesCount;
     }
     $this->currentPage = $currentPage;
     $this->paginator->getQuery()->setFirstResult($this->limit * ($this->currentPage - 1))->setMaxResults($this->limit);
     $this->query = $query;
 }
开发者ID:breathbath,项目名称:airbnbclone,代码行数:18,代码来源:Paginator.php

示例3: paginate

 /**
  * Paginator Helper
  * Pass through a query object, current page & limit
  * the offset is calculated from the page and limit
  * returns an `Paginator` instance, which you can call the following on:
  * $paginator->getIterator()->count() # Total fetched (ie: `5` posts)
  * $paginator->count() # Count of ALL posts (ie: `20` posts)
  * $paginator->getIterator() # ArrayIterator
  * 
  * @param Doctrine\ORM\Query $dql
  *            DQL Query Object
  * @param integer $page
  *            Current page (defaults to 1)
  * @param integer $limit
  *            The total number per page (defaults to 5)
  * @return \Doctrine\ORM\Tools\Pagination\Paginator
  */
 public function paginate($dql, $page = 1, $limit = 15)
 {
     $paginator = new Paginator($dql);
     $paginator->getQuery()->setFirstResult($limit * ($page - 1))->setMaxResults($limit);
     // Limit
     return $paginator;
 }
开发者ID:Kaik,项目名称:KaikMediaGallery,代码行数:24,代码来源:MediaRepository.php

示例4: findByCollector

 /**
  * @param string $collector
  * @param int    $page
  * @param int    $maxItemPerPage
  *
  * @return Paginator
  */
 public function findByCollector($collector, $page, $maxItemPerPage)
 {
     $query = $this->createQueryBuilder('c')->where('c.collector = :collector')->setParameter('collector', $collector)->getQuery();
     $paginator = new Paginator($query);
     $paginator->getQuery()->setFirstResult($maxItemPerPage * ($page - 1))->setMaxResults($maxItemPerPage);
     return $paginator;
 }
开发者ID:deuzu,项目名称:request-collector-bundle,代码行数:14,代码来源:RequestCollectorRepository.php

示例5: __construct

 /**
  * @param Query|QueryBuilder $query
  * @param int                $perPage
  * @param int                $page
  */
 public function __construct($query, $perPage, $page)
 {
     $paginator = new Paginator($query);
     $paginator->getQuery()->setFirstResult($perPage * ($page - 1))->setMaxResults($perPage);
     $this->resource = $paginator;
     $this->page = $page;
     $this->perPage = $perPage;
 }
开发者ID:bzis,项目名称:zomba,代码行数:13,代码来源:PaginationHelper.php

示例6: __construct

 public function __construct(DoctrineOrmPaginator $paginator)
 {
     $this->paginator = $paginator;
     $this->query = $paginator->getQuery();
     $this->firstResult = $this->query->getFirstResult();
     $this->maxResults = $this->query->getMaxResults();
     $this->totalItems = count($paginator);
 }
开发者ID:reminec,项目名称:DunglasApiBundle,代码行数:8,代码来源:Paginator.php

示例7: paginate

 public function paginate($dql, $offset = 1, $limit = 10)
 {
     if ($limit > 100 || $limit <= 0) {
         $limit = 100;
     }
     $paginator = new Paginator($dql, false);
     $paginator->getQuery()->setMaxResults($limit)->setFirstResult(($offset - 1) * $limit);
     return $paginator;
 }
开发者ID:RomainMarecat,项目名称:purchase_order,代码行数:9,代码来源:AbstractEntityRepository.php

示例8: findAllStartsWith

 public function findAllStartsWith($letter, $page, $per_page)
 {
     $query = $this->joinQuery();
     if ($letter != 'ALL') {
         $query->where('s.name LIKE :letter')->setParameter('letter', "{$letter}%");
     }
     $query->orderBy('s.name', 'ASC')->addOrderBy('p.name', 'ASC')->addOrderBy('i.imageName', 'ASC');
     $paginator = new Paginator($query, $fetchJoinCollection = true);
     $paginator->getQuery()->setFirstResult(($page - 1) * $per_page)->setMaxResults($per_page);
     return $paginator;
 }
开发者ID:revgum,项目名称:symfony-sandbox,代码行数:11,代码来源:SiteRepository.php

示例9: paginate

 /**
  * Generate paginated output
  *
  * @param \Doctrine\ORM\QueryBuilder $qb
  * @param int                        $limit
  * @param int                        $offset
  *
  * @return \FOS\RestBundle\View\View
  */
 protected function paginate(\Doctrine\ORM\QueryBuilder $qb, $limit = null, $offset = null)
 {
     if ($offset != null && intval($offset) > 0) {
         $qb->setFirstResult($offset);
     }
     if ($limit != null && intval($limit) > 0) {
         $qb->setMaxResults($limit);
     }
     $paginator = new Paginator($qb, $fetchJoinCollection = true);
     $view = $this->createView($paginator->getQuery()->getResult());
     $view->setHeader('X-Pagination-Total-Results', count($paginator));
     return $view;
 }
开发者ID:jmsteinmetz,项目名称:Dime,代码行数:22,代码来源:DimeController.php

示例10: paginate

 public static function paginate($query, &$pageSize = 10, &$currentPage = 1)
 {
     $pageSize = (int) $pageSize;
     $currentPage = (int) $currentPage;
     if ($pageSize < 1) {
         $pageSize = 10;
     }
     if ($currentPage < 1) {
         $currentPage = 1;
     }
     $paginator = new Paginator($query);
     $paginator->getQuery()->setFirstResult($pageSize * ($currentPage - 1))->setMaxResults($pageSize);
     return $paginator;
 }
开发者ID:mudruy,项目名称:tracker,代码行数:14,代码来源:DoctrineHelp.php

示例11: findByAccount

 /**
  * recuperer les transactions d un compte et entres 2 dates
  * @param type $oAccount
  * @param type $sDateBegin
  * @param type $sDateEnd
  * @return null
  */
 public function findByAccount($oAccount, $sDateBegin, $sDateEnd, $oCategory = null, $sWording = null, $sOperation = null, $nFirstResult = null, $nPerPage = null)
 {
     try {
         if (is_null($nPerPage)) {
             $nPerPage = self::PER_PAGE;
         }
         $sOperator = null;
         if (!is_null($sOperation)) {
             $sOperator = '<';
             if ($sOperation == self::CREDIT) {
                 $sOperator = '>';
             }
         }
         $oQB = $this->createQueryBuilder('t');
         $oQB->innerJoin('t.account', 'a');
         $oQB->innerJoin('t.category', 'c');
         $oQB->OrderBy('t.date', 'ASC');
         $oQB->where('t.account = :account')->setParameter('account', $oAccount);
         $oQB->andWhere('t.date >= :date_b ')->setParameter('date_b', $sDateBegin);
         $oQB->andWhere('t.date <= :date_f ')->setParameter('date_f', $sDateEnd);
         if (!is_null($sOperator)) {
             $oQB->andWhere('t.amount ' . $sOperator . ' :val')->setParameter('val', 0);
         }
         if (!is_null($oCategory)) {
             $oQB->andWhere('t.category = :category')->setParameter('category', $oCategory);
         }
         if (!is_null($sWording)) {
             $oQB->andWhere('t.wording LIKE :word')->setParameter('word', '%' . $sWording . '%');
         }
         $oQB->addSelect('c');
         $oQB->addSelect('a');
         $nTotalResult = count($oQB->getQuery()->getResult());
         if (!is_null($nFirstResult)) {
             $oQB->setFirstResult($nFirstResult);
             $oQB->setMaxResults($nPerPage);
             $paginator = new Paginator($oQB->getQuery(), $fetchJoinCollection = true);
             return array('TotalRecordCount' => $nTotalResult, 'Records' => $paginator->getQuery()->getResult());
         }
         return $oQB->getQuery()->getResult();
     } catch (NoResultException $ex) {
         return null;
     }
 }
开发者ID:abdessamad-oue,项目名称:SpendingAnalyzer,代码行数:50,代码来源:TransactionRepository.php

示例12: getSlice

 /**
  * {@inheritdoc}
  */
 public function getSlice($offset, $length)
 {
     $this->paginator->getQuery()->setFirstResult($offset)->setMaxResults($length);
     return $this->paginator->getIterator();
 }
开发者ID:yakamoz-fang,项目名称:concrete,代码行数:8,代码来源:DoctrineORMAdapter.php

示例13: getItems

 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getItems($offset, $limit)
 {
     $this->paginator->getQuery()->setFirstResult($offset)->setMaxResults($limit);
     return iterator_to_array($this->paginator->getIterator());
 }
开发者ID:kgilden,项目名称:pager,代码行数:10,代码来源:DqlAdapter.php

示例14: searchUsers

 public function searchUsers($filters)
 {
     $entityManager = $this->getEntityManager();
     $query = $entityManager->createQueryBuilder();
     if ($filters['fields']) {
         $fields = 'partial u.{' . implode($this->getFieldsAndOrFilter($filters['fields']), ',') . '}';
     } else {
         $fields = 'partial u.{' . implode($this->getFieldsAndOrFilter(), ',') . '}';
     }
     $query->select($fields);
     $query->from('Api:User', 'u');
     if ($filters['query']) {
         foreach ($filters['query'] as $q) {
             if ($q['operator'] == '=' || $q['operator'] == 'LIKE') {
                 $query->andWhere('u.' . $q['field'] . ' ' . $q['operator'] . ' :' . $q['field']);
                 $query->setParameter($q['field'], $q['values']);
             } elseif ($q['operator'] == 'IN') {
                 $query->andWhere('u.' . $q['field'] . ' ' . $q['operator'] . ' (:' . $q['field'] . ')');
                 $query->setParameter($q['field'], $q['values']);
             } elseif ($q['operator'] == 'BETWEEN') {
                 $query->andWhere('u.' . $q['field'] . ' ' . $q['operator'] . ' :' . $q['field'] . 'A AND :' . $q['field'] . 'B');
                 $query->setParameter($q['field'] . 'A', $q['values'][0]);
                 $query->setParameter($q['field'] . 'B', $q['values'][1]);
             }
         }
     }
     if ($filters['sort']) {
         foreach ($filters['sort'] as $key => $value) {
             $query->addOrderBy('u.' . $key, $value);
         }
     }
     if ($filters['offset']) {
         $query->setFirstResult($filters['offset']);
     }
     if ($filters['limit']) {
         $query->setMaxResults($filters['limit']);
     } else {
         $query->setMaxResults(10);
     }
     $paginator = new Paginator($query, true);
     $results = $paginator->getQuery()->getResult(Query::HYDRATE_ARRAY);
     return ['metadata' => ['total_rows' => count($paginator), 'result_rows' => count($results)], 'results' => $results];
 }
开发者ID:danielspk,项目名称:tornadohttpskeletonapplication,代码行数:43,代码来源:UserRepository.php

示例15: paginate

 private function paginate($query, $offset, $limit)
 {
     $paginator = new Paginator($query);
     $paginator->getQuery()->setFirstResult($offset)->setMaxResults($limit);
     return $paginator;
 }
开发者ID:Kid-Binary,项目名称:Boilerplate,代码行数:6,代码来源:PaginatorTrait.php


注:本文中的Doctrine\ORM\Tools\Pagination\Paginator::getQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。