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


PHP Criteria::getMaxResults方法代码示例

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


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

示例1: testConstructor

 public function testConstructor()
 {
     $expr = new Comparison("field", "=", "value");
     $criteria = new Criteria($expr, array("foo" => "ASC"), 10, 20);
     $this->assertSame($expr, $criteria->getWhereExpression());
     $this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings());
     $this->assertEquals(10, $criteria->getFirstResult());
     $this->assertEquals(20, $criteria->getMaxResults());
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:9,代码来源:CriteriaTest.php

示例2: apply

 /**
  * {@inheritdoc}
  */
 public function apply(Criteria $criteria, FilterValue $value = null)
 {
     $val = null !== $value ? $value->getValue() : $this->getDefaultValue();
     if (null !== $val) {
         $pageSize = $criteria->getMaxResults();
         if (null !== $pageSize) {
             $criteria->setFirstResult(QueryUtils::getPageOffset($val, $pageSize));
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:PageNumberFilter.php

示例3: addCriteria

 /**
  * @param QueryBuilder $qb
  * @param Criteria     $criteria
  */
 public static function addCriteria(QueryBuilder $qb, Criteria $criteria)
 {
     $rootAlias = $qb->getRootAlias();
     $visitor = new QueryExpressionVisitor($rootAlias);
     if ($whereExpression = $criteria->getWhereExpression()) {
         $qb->andWhere($visitor->dispatch($whereExpression));
         foreach ($visitor->getParameters() as $parameter) {
             $qb->getParameters()->add($parameter);
         }
     }
     if ($criteria->getOrderings()) {
         foreach ($criteria->getOrderings() as $sort => $order) {
             $qb->addOrderBy($rootAlias . '.' . $sort, $order);
         }
     }
     // Overwrite limits only if they was set in criteria
     if (($firstResult = $criteria->getFirstResult()) !== null) {
         $qb->setFirstResult($firstResult);
     }
     if (($maxResults = $criteria->getMaxResults()) !== null) {
         $qb->setMaxResults($maxResults);
     }
 }
开发者ID:nmallare,项目名称:platform,代码行数:27,代码来源:QueryBuilderHelper.php

示例4: loadCriteria

    /**
     * Loads Entities matching the given Criteria object.
     *
     * @param \Doctrine\Common\Collections\Criteria $criteria
     *
     * @return array
     */
    public function loadCriteria(Criteria $criteria)
    {
        $orderBy = $criteria->getOrderings();
        $limit   = $criteria->getMaxResults();
        $offset  = $criteria->getFirstResult();
        $query   = $this->getSelectSQL($criteria, null, 0, $limit, $offset, $orderBy);

        list($params, $types) = $this->expandCriteriaParameters($criteria);

        $stmt       = $this->conn->executeQuery($query, $params, $types);
        $hydrator   = $this->em->newHydrator(($this->selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT);

        return $hydrator->hydrateAll($stmt, $this->rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true));
    }
开发者ID:nattaphat,项目名称:hgis,代码行数:21,代码来源:BasicEntityPersister.php

示例5: addCriteria

 /**
  * Adds criteria to the query.
  *
  * Adds where expressions with AND operator.
  * Adds orderings.
  * Overrides firstResult and maxResults if they're set.
  *
  * @param Criteria $criteria
  * @return QueryBuilder
  * @throws Query\QueryException
  */
 public function addCriteria(Criteria $criteria)
 {
     $allAliases = $this->getAllAliases();
     if (!isset($allAliases[0])) {
         throw new Query\QueryException('No aliases are set before invoking addCriteria().');
     }
     $visitor = new QueryExpressionVisitor($this->getAllAliases());
     if ($whereExpression = $criteria->getWhereExpression()) {
         $this->andWhere($visitor->dispatch($whereExpression));
         foreach ($visitor->getParameters() as $parameter) {
             $this->parameters->add($parameter);
         }
     }
     if ($criteria->getOrderings()) {
         foreach ($criteria->getOrderings() as $sort => $order) {
             $hasValidAlias = false;
             foreach ($allAliases as $alias) {
                 if (strpos($sort . '.', $alias . '.') === 0) {
                     $hasValidAlias = true;
                     break;
                 }
             }
             if (!$hasValidAlias) {
                 $sort = $allAliases[0] . '.' . $sort;
             }
             $this->addOrderBy($sort, $order);
         }
     }
     // Overwrite limits only if they was set in criteria
     if (($firstResult = $criteria->getFirstResult()) !== null) {
         $this->setFirstResult($firstResult);
     }
     if (($maxResults = $criteria->getMaxResults()) !== null) {
         $this->setMaxResults($maxResults);
     }
     return $this;
 }
开发者ID:Dren-x,项目名称:mobitnew,代码行数:48,代码来源:QueryBuilder.php

示例6: addCriteria

 /**
  * Add criteria to query.
  * Add where expressions with AND operator.
  * Add orderings.
  * Override firstResult and maxResults if they set.
  *
  * @param Criteria $criteria
  * @return QueryBuilder
  */
 public function addCriteria(Criteria $criteria)
 {
     $visitor = new QueryExpressionVisitor();
     if ($whereExpression = $criteria->getWhereExpression()) {
         $this->andWhere($visitor->dispatch($whereExpression));
         foreach ($visitor->getParameters() as $parameter) {
             $this->parameters->add($parameter);
         }
     }
     if ($criteria->getOrderings()) {
         foreach ($criteria->getOrderings() as $sort => $order) {
             $this->addOrderBy($sort, $order);
         }
     }
     // Overwrite limits only if they was set in criteria
     if (($firstResult = $criteria->getFirstResult()) !== null) {
         $this->setFirstResult($firstResult);
     }
     if (($maxResults = $criteria->getMaxResults()) !== null) {
         $this->setMaxResults($maxResults);
     }
     return $this;
 }
开发者ID:relo-san,项目名称:doctrine2,代码行数:32,代码来源:QueryBuilder.php

示例7: loadCriteria

 /**
  * {@inheritdoc}
  */
 public function loadCriteria(Criteria $criteria)
 {
     $orderBy = $criteria->getOrderings();
     $limit = $criteria->getMaxResults();
     $offset = $criteria->getFirstResult();
     $query = $this->persister->getSelectSQL($criteria);
     $hash = $this->getHash($query, $criteria, $orderBy, $limit, $offset);
     $rsm = $this->getResultSetMapping();
     $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey);
     $queryCache = $this->cache->getQueryCache($this->regionName);
     $cacheResult = $queryCache->get($queryKey, $rsm);
     if ($cacheResult !== null) {
         if ($this->cacheLogger) {
             $this->cacheLogger->queryCacheHit($this->regionName, $queryKey);
         }
         return $cacheResult;
     }
     $result = $this->persister->loadCriteria($criteria);
     $cached = $queryCache->put($queryKey, $rsm, $result);
     if ($this->cacheLogger) {
         if ($result) {
             $this->cacheLogger->queryCacheMiss($this->regionName, $queryKey);
         }
         if ($cached) {
             $this->cacheLogger->queryCachePut($this->regionName, $queryKey);
         }
     }
     return $result;
 }
开发者ID:naldz,项目名称:cyberden,代码行数:32,代码来源:AbstractEntityPersister.php

示例8: loadCriteria

 /**
  * Load Entities matching the given Criteria object
  *
  * @param \Doctrine\Common\Collections\Criteria $criteria
  *
  * @return array
  */
 public function loadCriteria(Criteria $criteria)
 {
     $orderBy = $criteria->getOrderings();
     $limit = $criteria->getMaxResults();
     $offset = $criteria->getFirstResult();
     $sql = $this->_getSelectEntitiesSQL($criteria, null, 0, $limit, $offset, $orderBy);
     list($params, $types) = $this->expandCriteriaParameters($criteria);
     $stmt = $this->_conn->executeQuery($sql, $params, $types);
     $hydrator = $this->_em->newHydrator($this->_selectJoinSql ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT);
     return $hydrator->hydrateAll($stmt, $this->_rsm, array('deferEagerLoads' => true));
 }
开发者ID:laiello,项目名称:masfletes,代码行数:18,代码来源:BasicEntityPersister.php

示例9: matching

 /**
  * {@inheritDoc}
  */
 public function matching(Criteria $criteria)
 {
     $expr = $criteria->getWhereExpression();
     $filtered = $this->elements;
     if ($expr) {
         $visitor = new ClosureExpressionVisitor();
         $filter = $visitor->dispatch($expr);
         $filtered = array_filter($filtered, $filter);
     }
     if ($orderings = $criteria->getOrderings()) {
         foreach (array_reverse($orderings) as $field => $ordering) {
             $next = ClosureExpressionVisitor::sortByField($field, $ordering == Criteria::DESC ? -1 : 1);
         }
         usort($filtered, $next);
     }
     $offset = $criteria->getFirstResult();
     $length = $criteria->getMaxResults();
     if ($offset || $length) {
         $filtered = array_slice($filtered, (int) $offset, $length);
     }
     return new static($filtered);
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:25,代码来源:ArrayCollection.php

示例10: matching

 /**
  * Selects all elements from a selectable that match the expression and
  * returns a new collection containing these elements.
  *
  * @see Selectable::matching()
  * @param Criteria $criteria
  * @return Collection
  */
 public function matching(Criteria $criteria)
 {
     $visitor = new QueryExpressionVisitor($this->createQueryBuilder());
     $queryBuilder = $this->createQueryBuilder();
     if ($criteria->getWhereExpression() !== null) {
         $expr = $visitor->dispatch($criteria->getWhereExpression());
         $queryBuilder->setQueryArray($expr->getQuery());
     }
     if ($criteria->getMaxResults() !== null) {
         $queryBuilder->limit($criteria->getMaxResults());
     }
     if ($criteria->getFirstResult() !== null) {
         $queryBuilder->skip($criteria->getFirstResult());
     }
     if ($criteria->getOrderings() !== null) {
         $queryBuilder->sort($criteria->getOrderings());
     }
     // @TODO: wrap around a specialized Collection for efficient count on large collections
     return new ArrayCollection($queryBuilder->getQuery()->execute()->toArray());
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:28,代码来源:DocumentRepository.php

示例11: serialize

 /**
  * Serializes a the given criteria to a PHP serialized format.
  *
  * @param Criteria $criteria The criteria to serialize.
  * @return string
  */
 public function serialize(Criteria $criteria)
 {
     $structure = array('whereExpression' => $this->dispatch($criteria->getWhereExpression()), 'firstResult' => $criteria->getFirstResult(), 'maxResults' => $criteria->getMaxResults(), 'orderings' => $criteria->getOrderings());
     return serialize($structure);
 }
开发者ID:waltertamboer,项目名称:doctrine-criteria-serializer,代码行数:11,代码来源:CriteriaSerializer.php

示例12: testReturnsCorrectCount

 /**
  * @covers \DoctrineModule\Paginator\Adapter\Selectable::count
  */
 public function testReturnsCorrectCount()
 {
     $selectable = $this->getMock('Doctrine\\Common\\Collections\\Selectable');
     $expression = Criteria::expr()->eq('foo', 'bar');
     $criteria = new Criteria($expression, array('baz' => Criteria::DESC), 10, 20);
     $adapter = new SelectableAdapter($selectable, $criteria);
     $selectable->expects($this->once())->method('matching')->with($this->callback(function (Criteria $criteria) use($expression) {
         return $criteria->getWhereExpression() == $expression && array('baz' => Criteria::DESC) === $criteria->getOrderings() && null === $criteria->getFirstResult() && null === $criteria->getMaxResults();
     }))->will($this->returnValue(new ArrayCollection(range(1, 101))));
     $this->assertEquals(101, $adapter->count());
     $this->assertSame(10, $criteria->getFirstResult(), 'Original criteria was not modified');
     $this->assertSame(20, $criteria->getMaxResults(), 'Original criteria was not modified');
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:16,代码来源:SelectableAdapterTest.php

示例13: matching

 /**
  * Select all elements from a selectable that match the criteria and
  * return a new collection containing these elements.
  *
  * @param  Criteria $criteria
  * @return Collection2
  */
 public function matching(Criteria $criteria)
 {
     $this->initialize();
     $expr = $criteria->getWhereExpression();
     $filtered = $this->entities;
     if ($expr) {
         $visitor = new ClosureExpressionVisitor();
         $filter = $visitor->dispatch($expr);
         $filtered = array_filter($filtered, $filter);
     }
     if (null !== ($orderings = $criteria->getOrderings())) {
         $next = null;
         foreach (array_reverse($orderings) as $field => $ordering) {
             $next = ClosureExpressionVisitor::sortByField($field, $ordering == 'DESC' ? -1 : 1, $next);
         }
         usort($filtered, $next);
     }
     $offset = $criteria->getFirstResult();
     $length = $criteria->getMaxResults();
     if ($offset || $length) {
         $filtered = array_slice($filtered, (int) $offset, $length);
     }
     return new ArrayCollection($filtered);
 }
开发者ID:ezprit,项目名称:JMSJobQueueBundle,代码行数:31,代码来源:PersistentRelatedEntitiesCollection.php

示例14: cloneCriteria

 /**
  * Makes a clone of the given Criteria
  *
  * @param Criteria $criteria
  *
  * @return Criteria
  */
 protected function cloneCriteria(Criteria $criteria)
 {
     return new Criteria($criteria->getWhereExpression(), $criteria->getOrderings(), $criteria->getFirstResult(), $criteria->getMaxResults());
 }
开发者ID:2ndkauboy,项目名称:platform,代码行数:11,代码来源:AssociationManager.php

示例15: getLimitSql

 /**
  * @param Criteria $criteria
  * @return string
  * @throws \Doctrine\DBAL\DBALException
  */
 private function getLimitSql(Criteria $criteria)
 {
     $limit = $criteria->getMaxResults();
     $offset = $criteria->getFirstResult();
     if ($limit !== null || $offset !== null) {
         return $this->platform->modifyLimitQuery('', $limit, $offset);
     }
     return '';
 }
开发者ID:AdactiveSAS,项目名称:doctrine2,代码行数:14,代码来源:ManyToManyPersister.php


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