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


PHP ModelCriteria::limit方法代码示例

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


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

示例1: testFindOneWithClassAndColumn

 public function testFindOneWithClassAndColumn()
 {
     BookstoreDataPopulator::populate();
     BookTableMap::clearInstancePool();
     AuthorTableMap::clearInstancePool();
     ReviewTableMap::clearInstancePool();
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
     $c->filterByTitle('The Tin Drum');
     $c->join('Propel\\Tests\\Bookstore\\Book.Author');
     $c->withColumn('Author.FirstName', 'AuthorName');
     $c->withColumn('Author.LastName', 'AuthorName2');
     $c->with('Author');
     $c->limit(1);
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     $books = $c->find($con);
     foreach ($books as $book) {
         break;
     }
     $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class');
     $this->assertEquals('The Tin Drum', $book->getTitle());
     $this->assertTrue($book->getAuthor() instanceof Author, 'ObjectFormatter correctly hydrates with class');
     $this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'ObjectFormatter correctly hydrates with class');
     $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'ObjectFormatter adds withColumns as virtual columns');
     $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'ObjectFormatter correctly hydrates all virtual columns');
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:26,代码来源:OnDemandFormatterWithTest.php

示例2: testOffset

 public function testOffset()
 {
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->limit(50);
     $c->offset(10);
     if ($this->isDb('mysql')) {
         $sql = 'SELECT  FROM  LIMIT 10, 50';
     } else {
         $sql = 'SELECT  FROM  LIMIT 50 OFFSET 10';
     }
     $params = array();
     $this->assertCriteriaTranslation($c, $sql, $params, 'offset() adds an OFFSET clause');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:ModelCriteriaTest.php

示例3: testFindOneWithOneToManyAndLimit

 /**
  * @expectedException \Propel\Runtime\Exception\LogicException
  */
 public function testFindOneWithOneToManyAndLimit()
 {
     $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
     $c->add(BookTableMap::COL_ISBN, '043935806X');
     $c->leftJoin('Book.Review');
     $c->with('Review');
     $c->limit(5);
     $books = $c->find();
 }
开发者ID:disider,项目名称:Propel2,代码行数:12,代码来源:ObjectFormatterWithTest.php

示例4: searchWithOffset

 /**
  * @param ModelCriteria $search
  *
  * @return ObjectCollection
  */
 protected function searchWithOffset(ModelCriteria $search)
 {
     $limit = intval($this->getArgValue('limit'));
     if ($limit >= 0) {
         $search->limit($limit);
     }
     $search->offset(intval($this->getArgValue('offset')));
     return $search->find();
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:14,代码来源:BaseLoop.php

示例5: mapOptions

 /**
  * Maps options like limit, offset, order
  *
  * @param ModelCriteria $query
  * @param array $options
  *
  * @throws FileNotFoundException
  */
 public function mapOptions(ModelCriteria $query, $options = array())
 {
     if (isset($options['limit'])) {
         $query->limit($options['limit']);
     }
     if (isset($options['offset'])) {
         $query->offset($options['offset']);
     }
     if (isset($options['order']) && is_array($options['order'])) {
         foreach ($options['order'] as $field => $direction) {
             $fieldName = ucfirst($field);
             $tableMap = $this->tableMap;
             if (false !== ($pos = strpos($field, '.'))) {
                 $relationName = ucfirst(substr($field, 0, $pos));
                 $fieldName = ucfirst(substr($field, $pos + 1));
                 if (!($relation = $this->tableMap->getRelation($relationName))) {
                     throw new FileNotFoundException(sprintf('Relation `%s` in object `%s` not found', $relationName, $this->getObjectKey()));
                 }
                 $tableMap = $relation->getForeignTable();
             }
             if ($tableMap->hasColumnByPhpName(ucfirst($fieldName))) {
                 $column = $this->tableMap->getColumnByPhpName(ucfirst($fieldName));
                 $query->orderBy($column->getName(), $direction);
             }
         }
     }
 }
开发者ID:jarves,项目名称:jarves,代码行数:35,代码来源:Propel.php

示例6: testFindOneWithOneToManyAndLimit

 /**
  * @expectedException \Propel\Runtime\Exception\LogicException
  */
 public function testFindOneWithOneToManyAndLimit()
 {
     $c = new ModelCriteria('bookstore', '\\Propel\\Tests\\Bookstore\\Book');
     $c->setFormatter(ModelCriteria::FORMAT_ARRAY);
     $c->add(BookTableMap::ISBN, '043935806X');
     $c->leftJoin('Propel\\Tests\\Bookstore\\Book.Review');
     $c->with('Review');
     $c->limit(5);
     $books = $c->find();
 }
开发者ID:badelas,项目名称:thelia,代码行数:13,代码来源:ArrayFormatterWithTest.php


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