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


PHP Query::setFirstResult方法代码示例

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


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

示例1: setPagerParameters

 /**
  * @param Query $pageQuery
  */
 protected function setPagerParameters(Query $pageQuery)
 {
     $pageQuery->setFirstResult($this->getFirstResult());
     $pageQuery->setMaxResults($this->bufferSize);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:8,代码来源:ConstantPagerIterableResult.php

示例2: applyPaging

 /**
  * @param int
  * @param int
  * @return ResultSet
  */
 public function applyPaging($offset, $limit)
 {
     if ($this->query->getFirstResult() != $offset || $this->query->getMaxResults() != $limit) {
         $this->query->setFirstResult($offset);
         $this->query->setMaxResults($limit);
         $this->iterator = NULL;
     }
     return $this;
 }
开发者ID:librette,项目名称:doctrine-queries,代码行数:14,代码来源:ResultSet.php

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

示例4: paginate

 public function paginate($page, Query $query, $itemsPerPage = 10)
 {
     if (!is_numeric($page)) {
         throw new \Exception('Valor no numerico para la paginacion');
     }
     $this->currentPage = (int) $page;
     $this->itemsPerPage = $itemsPerPage;
     $this->calLastPage(count($query->getResult()));
     $this->calRange();
     $query->setFirstResult($this->offset())->setMaxResults($this->itemsPerPage);
     return $query->getResult();
 }
开发者ID:rimitola8511,项目名称:PaginatorBundle,代码行数:12,代码来源:Paginator.php

示例5: _getNextBatch

 private function _getNextBatch()
 {
     if ($this->clearEntitiesOnBatch) {
         $em = $this->query->getEntityManager();
         foreach ($this->clearEntitiesOnBatch as $e) {
             $em->clear($e);
         }
     }
     if (!$this->_count || $this->_count == $this->resultsPerBatch) {
         if ($this->countTotal && $this->offset + $this->resultsPerBatch > $this->countTotal) {
             $maxResults = $this->countTotal - $this->offset;
         } else {
             $maxResults = $this->resultsPerBatch;
         }
         $this->results = $this->query->setFirstResult($this->offset)->setMaxResults($maxResults)->getResult($this->hydrationMode);
     } else {
         $this->results = array();
     }
     $this->offset += $this->resultsPerBatch;
     $this->_index = 0;
     $this->_count = count($this->results);
 }
开发者ID:cyantree,项目名称:grout,代码行数:22,代码来源:DoctrineBatchReader.php

示例6: getPaginatedResult

 /**
  * @param Query|QueryBuilder $query
  * @param int                $page
  * @param int                $limit
  * @param Closure            $callback
  *
  * @return array
  */
 public function getPaginatedResult($query, $page, $limit, $callback = null)
 {
     $query->setFirstResult(($page - 1) * $limit)->setMaxResults($limit);
     if ($query instanceof QueryBuilder) {
         $query = $query->getQuery();
     }
     $items = $query->getResult();
     if ($callback == null) {
         $callback = function ($item) {
             return ['id' => $item->getId(), 'text' => (string) $item];
         };
     }
     $data = array_map($callback, $items);
     $more = count($data) >= $limit;
     return ['items' => $data, 'itemsPerPage' => $limit, 'more' => $more];
 }
开发者ID:rotanov,项目名称:fefu-social-network,代码行数:24,代码来源:Paginator.php

示例7: paginate

 /**
  * {@inheritdoc}
  */
 public function paginate(Query $query, $results, $offset, $arrayResult = true)
 {
     if ($results <= 0 || $results > $this->maxResults) {
         $results = $this->defaultResults;
     }
     if ($offset < 0) {
         $offset = 0;
     }
     $paginator = new Paginator($query, false);
     $query->setFirstResult($offset)->setMaxResults($results);
     if ($arrayResult) {
         $result = $query->getArrayResult();
     } else {
         $result = $query->getResult();
     }
     return ['recordsTotal' => count($paginator), 'recordsFiltered' => count($paginator), 'data' => $result];
 }
开发者ID:mangati,项目名称:base-bundle,代码行数:20,代码来源:DataTables.php

示例8: getPaginator

 /**
  * Create and returns a doctrine pagination.
  *
  * @param Query $query the doctrine object query
  * @param int   $currentPageNumber current page
  * @param int   $itemCountPerPage items per page
  *
  * @return Paginator
  */
 public function getPaginator(Query $query, $currentPageNumber = null, $itemCountPerPage = null)
 {
     $this->setPagination($currentPageNumber, $itemCountPerPage);
     $query->setFirstResult($this->firstResult)->setMaxResults($this->maxResults);
     return new Paginator($query);
 }
开发者ID:fagundes,项目名称:zff-base,代码行数:15,代码来源:AbstractService.php

示例9: 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

示例10: offset

 /**
  * Creates offset.
  *
  * @access   public
  * @param    integer $iVal
  * @return   $this
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function offset($iVal)
 {
     $this->oQuery->setFirstResult($iVal);
     return $this;
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:14,代码来源:DB.php

示例11: prepareQueryToExecute

 /**
  * {@inheritdoc}
  */
 protected function prepareQueryToExecute(Query $query)
 {
     // always iterate from the first record
     $query->setFirstResult($this->firstResult);
 }
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:DeletionQueryResultIterator.php

示例12: calculateFirstResult

 /**
  * Calculate first result based on page and max-per-page
  */
 protected function calculateFirstResult()
 {
     $maxPerPage = $this->getMaxPerPage();
     $page = $this->getPage();
     $this->query->setFirstResult($maxPerPage * ($page - 1));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:9,代码来源:IndexerPager.php

示例13: findCollectionSet

 /**
  * {@inheritdoc}
  */
 public function findCollectionSet($depth = 0, $filter = [], CollectionInterface $collection = null, $sortBy = [])
 {
     try {
         $dql = sprintf('SELECT n, collectionMeta, defaultMeta, collectionType, collectionParent, parentMeta, collectionChildren
              FROM %s AS n
                     LEFT OUTER JOIN n.meta AS collectionMeta
                     LEFT JOIN n.defaultMeta AS defaultMeta
                     LEFT JOIN n.type AS collectionType
                     LEFT JOIN n.parent AS collectionParent
                     LEFT JOIN n.children AS collectionChildren
                     LEFT JOIN collectionParent.meta AS parentMeta
              WHERE (n.depth <= :depth + :maxDepth OR collectionChildren.depth <= :maxDepthPlusOne)', $this->_entityName);
         if ($collection !== null) {
             $dql .= ' AND n.lft BETWEEN :lft AND :rgt AND n.id != :id';
         }
         if (array_key_exists('search', $filter) && $filter['search'] !== null) {
             $dql .= ' AND collectionMeta.title LIKE :search';
         }
         if (array_key_exists('locale', $filter)) {
             $dql .= ' AND (collectionMeta.locale = :locale OR defaultMeta != :locale)';
         }
         if ($sortBy !== null && is_array($sortBy) && sizeof($sortBy) > 0) {
             $orderBy = [];
             foreach ($sortBy as $column => $order) {
                 $orderBy[] = 'collectionMeta.' . $column . ' ' . (strtolower($order) === 'asc' ? 'ASC' : 'DESC');
             }
             $dql .= ' ORDER BY ' . implode(', ', $orderBy);
         }
         $query = new Query($this->_em);
         $query->setDQL($dql);
         $query->setParameter('maxDepth', intval($depth));
         $query->setParameter('maxDepthPlusOne', intval($depth) + 1);
         $query->setParameter('depth', $collection !== null ? $collection->getDepth() : 0);
         if ($collection !== null) {
             $query->setParameter('lft', $collection->getLft());
             $query->setParameter('rgt', $collection->getRgt());
             $query->setParameter('id', $collection->getId());
         }
         if (array_key_exists('search', $filter) && $filter['search'] !== null) {
             $query->setParameter('search', '%' . $filter['search'] . '%');
         }
         if (array_key_exists('limit', $filter)) {
             $query->setMaxResults($filter['limit']);
         }
         if (array_key_exists('offset', $filter)) {
             $query->setFirstResult($filter['offset']);
         }
         if (array_key_exists('locale', $filter)) {
             $query->setParameter('locale', $filter['locale']);
         }
         return new Paginator($query);
     } catch (NoResultException $ex) {
         return [];
     }
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:58,代码来源:CollectionRepository.php

示例14: getPaginateQuery

 /**
  * Given the Query it returns a new query that is a paginatable query
  * using a modified subselect.
  *
  * @param  Query $query
  * @return Query
  */
 public static function getPaginateQuery(Query $query, $offset, $itemCountPerPage, array $hints = array())
 {
     foreach ($hints as $name => $hint) {
         $query->setHint($name, $hint);
     }
     return $query->setFirstResult($offset)->setMaxResults($itemCountPerPage);
 }
开发者ID:php-pike,项目名称:pike,代码行数:14,代码来源:Paginate.php

示例15: applyPagingOptionsToQuery

 /**
  * Applies the paging configuration to the query object.
  *
  * @param Query        $query   Query object
  * @param QueryOptions $options Paging options
  */
 protected function applyPagingOptionsToQuery(Query $query, QueryOptions $options = null)
 {
     if ($options == null) {
         return;
     }
     if ($options->hasPagination()) {
         $query->setFirstResult(($options->page - 1) * $options->itemsPerPage);
         $query->setMaxResults($options->itemsPerPage);
     }
 }
开发者ID:proyecto404,项目名称:UtilBundle,代码行数:16,代码来源:EntityRepository.php


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