當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Query::setMaxResults方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\Query::setMaxResults方法的典型用法代碼示例。如果您正苦於以下問題:PHP Query::setMaxResults方法的具體用法?PHP Query::setMaxResults怎麽用?PHP Query::setMaxResults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\Query的用法示例。


在下文中一共展示了Query::setMaxResults方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: setMaxPerPage

 /**
  * @param int $maxPerPage
  */
 public function setMaxPerPage($maxPerPage)
 {
     if ($maxPerPage > 0) {
         $this->maxPerPage = $maxPerPage;
         $this->query->setMaxResults($maxPerPage);
     } else {
         $this->maxPerPage = 0;
         $this->query->setMaxResults(Query::INFINITY);
     }
     $this->calculateFirstResult();
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:14,代碼來源:IndexerPager.php

示例4: getQuery

 /**
  * @return Query
  * @throws \LogicException If source of a query is not valid
  */
 protected function getQuery()
 {
     if (null === $this->query) {
         if ($this->source instanceof Query) {
             $this->query = $this->cloneQuery($this->source);
         } elseif ($this->source instanceof QueryBuilder) {
             $this->query = $this->source->getQuery();
         } else {
             throw new \LogicException('Unexpected source');
         }
         unset($this->source);
         // initialize cloned query
         $this->maxResults = $this->query->getMaxResults();
         if (!$this->maxResults || $this->requestedBufferSize < $this->maxResults) {
             $this->query->setMaxResults($this->requestedBufferSize);
         }
         if (null !== $this->requestedHydrationMode) {
             $this->query->setHydrationMode($this->requestedHydrationMode);
         }
         $this->firstResult = (int) $this->query->getFirstResult();
     }
     return $this->query;
 }
開發者ID:snorchel,項目名稱:platform,代碼行數:27,代碼來源:BufferedQueryResultIterator.php

示例5: limit

 /**
  * Creates LIMIT clause.
  *
  * @access   public
  * @param    integer $iVal
  * @return   $this
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function limit($iVal)
 {
     $this->oQuery->setMaxResults($iVal);
     return $this;
 }
開發者ID:ktrzos,項目名稱:plethora,代碼行數:14,代碼來源:DB.php

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

示例7: newAction

        /**
     * @route: blog_new
     * Tag Controller
     */
    public function newAction()
    {
        // entity manager and query builder objects
        $em = $this->getEm();


        $query = new Query($em);
        $query->setDQL(
            'SELECT p,comments
                FROM Bundle\BlogBundle\Entity\Post p
                JOIN p.comments comments
                ORDER BY p.date DESC'
        );
        $query->setMaxResults(1);
        //$query->setParameter(1, $slug);
        $posts = $query->getResult();


        return $this->render('BlogBundle:Blog:post.html.twig', array(
            'post' => $posts[0]
        ));
    }
開發者ID:rdbsf,項目名稱:BlogBundle,代碼行數:26,代碼來源:BlogController.php

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

示例9: 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::setMaxResults方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。