當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。