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


PHP Query::getMaxResults方法代码示例

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


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

示例1: __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

示例2: getIterator

 /**
  * {@inheritdoc}
  */
 public function getIterator()
 {
     $offset = $this->query->getFirstResult();
     $length = $this->query->getMaxResults();
     if ($this->fetchJoinCollection) {
         $subQuery = $this->cloneQuery($this->query);
         $subQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\\ORM\\Tools\\Pagination\\LimitSubqueryWalker'))->setFirstResult($offset)->setMaxResults($length);
         $ids = array_map('current', $subQuery->getScalarResult());
         $whereInQuery = $this->cloneQuery($this->query);
         // don't do this for an empty id array
         if (count($ids) > 0) {
             $namespace = WhereInWalker::PAGINATOR_ID_ALIAS;
             $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\\ORM\\Tools\\Pagination\\WhereInWalker'));
             $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, count($ids));
             $whereInQuery->setFirstResult(null)->setMaxResults(null);
             foreach ($ids as $i => $id) {
                 $i++;
                 $whereInQuery->setParameter("{$namespace}_{$i}", $id);
             }
         }
         $result = $whereInQuery->getResult($this->query->getHydrationMode());
     } else {
         $result = $this->cloneQuery($this->query)->setMaxResults($length)->setFirstResult($offset)->getResult($this->query->getHydrationMode());
     }
     return new \ArrayIterator($result);
 }
开发者ID:pabloasc,项目名称:test_social,代码行数:29,代码来源:Paginator.php

示例3: getResult

 public function getResult()
 {
     $offset = $this->query->getFirstResult();
     $length = $this->query->getMaxResults();
     if ($this->fetchJoinCollection) {
         $subQuery = $this->cloneQuery($this->query);
         if ($this->useOutputWalker($subQuery)) {
             $subQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\\ORM\\Tools\\Pagination\\LimitSubqueryOutputWalker');
         } else {
             $this->appendTreeWalker($subQuery, 'Doctrine\\ORM\\Tools\\Pagination\\LimitSubqueryWalker');
         }
         $subQuery->setFirstResult($offset)->setMaxResults($length);
         $ids = array_map('current', $subQuery->getScalarResult());
         $whereInQuery = $this->cloneQuery($this->query);
         // don't do this for an empty id array
         if (count($ids) == 0) {
             return new \ArrayIterator(array());
         }
         $this->appendTreeWalker($whereInQuery, 'Doctrine\\ORM\\Tools\\Pagination\\WhereInWalker');
         $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, count($ids));
         $whereInQuery->setFirstResult(null)->setMaxResults(null);
         $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, $ids);
         $whereInQuery->setCacheable($this->query->isCacheable());
         $result = $whereInQuery->getResult($this->query->getHydrationMode());
     } else {
         $result = $this->cloneQuery($this->query)->setMaxResults($length)->setFirstResult($offset)->setCacheable($this->query->isCacheable())->getResult($this->query->getHydrationMode());
     }
     return $result;
 }
开发者ID:ratehub,项目名称:doctrine2,代码行数:29,代码来源:Paginator.php

示例4: getIterator

 /**
  * {@inheritdoc}
  */
 public function getIterator()
 {
     $offset = $this->query->getFirstResult();
     $length = $this->query->getMaxResults();
     if ($this->fetchJoinCollection) {
         $subQuery = $this->cloneQuery($this->query);
         $subQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Pagerfanta\\Adapter\\DoctrineORM\\LimitSubqueryWalker'))->setFirstResult($offset)->setMaxResults($length);
         $ids = array_map('current', $subQuery->getScalarResult());
         $whereInQuery = $this->cloneQuery($this->query);
         // don't do this for an empty id array
         if (count($ids) > 0) {
             $namespace = 'pg_';
             $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Pagerfanta\\Adapter\\DoctrineORM\\WhereInWalker'));
             $whereInQuery->setHint('id.count', count($ids));
             $whereInQuery->setHint('pg.ns', $namespace);
             $whereInQuery->setFirstResult(null)->setMaxResults(null);
             foreach ($ids as $i => $id) {
                 $i++;
                 $whereInQuery->setParameter("{$namespace}_{$i}", $id);
             }
         }
         return new \ArrayIterator($whereInQuery->getResult($this->query->getHydrationMode()));
     }
     $result = $this->cloneQuery($this->query)->setMaxResults($length)->setFirstResult($offset)->getResult($this->query->getHydrationMode());
     return new \ArrayIterator($result);
 }
开发者ID:pabloasc,项目名称:test_social,代码行数:29,代码来源:Paginator.php

示例5: __construct

 /**
  * Class constructor.
  *
  * @param \Doctrine\ORM\Query
  *
  * @throws \RuntimeException
  */
 public function __construct(Query $query)
 {
     if ($query->getFirstResult() !== null || $query->getMaxResults() !== null) {
         throw new \RuntimeException('Cannot build a QueryCollection from a Query ' . 'with firstResult or maxResults set.');
     }
     $this->query = $this->cloneQuery($query);
 }
开发者ID:e-ruiz,项目名称:brick,代码行数:14,代码来源:QueryCollection.php

示例6: __construct

 /**
  * Constructor.
  *
  * Stores various parameters that are otherwise unavailable
  * because Doctrine\ORM\Query\SqlWalker keeps everything private without
  * accessors.
  *
  * @param \Doctrine\ORM\Query              $query
  * @param \Doctrine\ORM\Query\ParserResult $parserResult
  * @param array                            $queryComponents
  */
 public function __construct($query, $parserResult, array $queryComponents)
 {
     $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform();
     $this->rsm = $parserResult->getResultSetMapping();
     $this->queryComponents = $queryComponents;
     // Reset limit and offset
     $this->firstResult = $query->getFirstResult();
     $this->maxResults = $query->getMaxResults();
     $query->setFirstResult(null)->setMaxResults(null);
     parent::__construct($query, $parserResult, $queryComponents);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:22,代码来源:LimitSubqueryOutputWalker.php

示例7: getIterator

 /**
  * @param int|null
  * @return \ArrayIterator
  */
 public function getIterator($hydrationMode = NULL)
 {
     if ($this->iterator !== NULL) {
         return $this->iterator;
     }
     if ($hydrationMode !== NULL) {
         $this->query->setHydrationMode($hydrationMode);
     }
     $this->frozen = TRUE;
     if ($this->fetchJoinCollection && ($this->query->getMaxResults() > 0 || $this->query->getFirstResult() > 0)) {
         $this->iterator = $this->createPaginatedQuery($this->query)->getIterator();
     } else {
         $this->iterator = new \ArrayIterator($this->query->getResult(NULL));
     }
     if ($this->repository && $this->queryObject) {
         $this->queryObject->queryFetched($this->repository, $this->iterator);
     }
     return $this->iterator;
 }
开发者ID:librette,项目名称:doctrine-queries,代码行数:23,代码来源:ResultSet.php

示例8: getIterator

 /**
  * @param int $hydrationMode
  * @throws QueryException
  * @return \ArrayIterator
  */
 public function getIterator($hydrationMode = ORM\AbstractQuery::HYDRATE_OBJECT)
 {
     if ($this->iterator !== NULL) {
         return $this->iterator;
     }
     $this->query->setHydrationMode($hydrationMode);
     try {
         $this->frozen = TRUE;
         if ($this->fetchJoinCollection && ($this->query->getMaxResults() > 0 || $this->query->getFirstResult() > 0)) {
             $this->iterator = $this->createPaginatedQuery($this->query)->getIterator();
         } else {
             $this->iterator = new \ArrayIterator($this->query->getResult(NULL));
         }
         if ($this->queryObject !== NULL && $this->repository !== NULL) {
             $this->queryObject->postFetch($this->repository, $this->iterator);
         }
         return $this->iterator;
     } catch (ORMException $e) {
         throw new QueryException($e, $this->query, $e->getMessage());
     }
 }
开发者ID:kdyby,项目名称:doctrine,代码行数:26,代码来源:ResultSet.php

示例9: useWalker

 /**
  * If flag to use walker not set manually we try to figure out if it will not brake query logic
  *
  * @param Query|SqlQuery $query
  *
  * @return bool
  */
 private function useWalker($query)
 {
     if ($query instanceof Query) {
         if (null === $this->shouldUseWalker) {
             return !$query->contains('GROUP BY') && null === $query->getMaxResults();
         }
         return $this->shouldUseWalker;
     }
     return false;
 }
开发者ID:northdakota,项目名称:platform,代码行数:17,代码来源:QueryCountCalculator.php

示例10: prepareQueryToExecute

 /**
  * Makes final preparation of a query object before its execute method will be called.
  *
  * @param Query $query
  */
 protected function prepareQueryToExecute(Query $query)
 {
     $query->setFirstResult($this->firstResult + $query->getMaxResults() * $this->page);
 }
开发者ID:snorchel,项目名称:platform,代码行数:9,代码来源:BufferedQueryResultIterator.php

示例11: getQueryCacheKey

 /**
  * @param Query $query
  *
  * @return string
  */
 public function getQueryCacheKey(Query $query)
 {
     $hints = $query->getHints();
     ksort($hints);
     return md5($query->getDql() . var_export($query->getParameters(), true) . var_export($hints, true) . '&firstResult=' . $query->getFirstResult() . '&maxResult=' . $query->getMaxResults() . '&hydrationMode=' . $query->getHydrationMode());
 }
开发者ID:treehouselabs,项目名称:cache-bundle,代码行数:11,代码来源:CachedEntityManager.php

示例12: fetch

 public function fetch(Query $query, $mode = self::FETCH_ALL)
 {
     if ($mode == self::FETCH_ALL) {
         if ($query->getMaxResults() !== null && $query->getHydrationMode() != self::HYDRATE_SINGLE_SCALAR) {
             return (new Paginator($query))->getIterator()->getArrayCopy();
         } else {
             return $query->execute();
         }
     } else {
         if ($mode == self::FETCH_ALL_PAGED) {
             return new Paginator($query);
         } else {
             if ($mode == self::FETCH_ONE) {
                 $query->setMaxResults(1);
                 if ($query->getHydrationMode() != self::HYDRATE_SINGLE_SCALAR) {
                     return (new Paginator($query))->getIterator()->current();
                 } else {
                     return $query->getOneOrNullResult();
                 }
             } else {
                 if ($mode == self::FETCH_ONE_UNIQUE) {
                     return $query->getOneOrNullResult();
                 }
             }
         }
     }
 }
开发者ID:jacksleight,项目名称:chalk,代码行数:27,代码来源:Repository.php


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