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


PHP Criteria::setOffset方法代碼示例

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


在下文中一共展示了Criteria::setOffset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: toCriteria

 /**
  * @inheritdoc
  */
 public function toCriteria()
 {
     $criteria = new Criteria();
     if ($this->filterTransfer->getLimit() !== null) {
         $criteria->setLimit($this->filterTransfer->getLimit());
     }
     if ($this->filterTransfer->getOffset() !== null) {
         $criteria->setOffset($this->filterTransfer->getOffset());
     }
     if ($this->filterTransfer->getOrderBy() !== null) {
         if ($this->filterTransfer->getOrderDirection() === 'ASC') {
             $criteria->addAscendingOrderByColumn($this->filterTransfer->getOrderBy());
         } elseif ($this->filterTransfer->getOrderDirection() === 'DESC') {
             $criteria->addDescendingOrderByColumn($this->filterTransfer->getOrderBy());
         }
     }
     return $criteria;
 }
開發者ID:spryker,項目名稱:Propel,代碼行數:21,代碼來源:PropelFilterCriteria.php

示例2: testMergeWithOffset

 public function testMergeWithOffset()
 {
     $c1 = new Criteria();
     $c1->setOffset(123);
     $c2 = new Criteria();
     $c1->mergeWith($c2);
     $this->assertEquals(123, $c1->getOffset(), 'mergeWith() does not remove an existing offset');
     $c1 = new Criteria();
     $c2 = new Criteria();
     $c2->setOffset(123);
     $c1->mergeWith($c2);
     $this->assertEquals(123, $c1->getOffset(), 'mergeWith() merges the offset');
     $c1 = new Criteria();
     $c1->setOffset(456);
     $c2 = new Criteria();
     $c2->setOffset(123);
     $c1->mergeWith($c2);
     $this->assertEquals(456, $c1->getOffset(), 'mergeWith() does not merge the offset in case of conflict');
 }
開發者ID:bondarovich,項目名稱:Propel2,代碼行數:19,代碼來源:CriteriaMergeTest.php

示例3: testMssqlApplyLimitWithOffsetMultipleOrderBy

 public function testMssqlApplyLimitWithOffsetMultipleOrderBy()
 {
     $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
     if (!$db instanceof MssqlAdapter) {
         $this->markTestSkipped('Configured database vendor is not MsSQL');
     }
     $c = new Criteria(BookTableMap::DATABASE_NAME);
     $c->addSelectColumn(BookTableMap::COL_ID);
     $c->addSelectColumn(BookTableMap::COL_TITLE);
     $c->addSelectColumn(PublisherTableMap::COL_NAME);
     $c->addAsColumn('PublisherName', '(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID)');
     $c->addJoin(BookTableMap::COL_PUBLISHER_ID, PublisherTableMap::COL_ID, Criteria::LEFT_JOIN);
     $c->addDescendingOrderByColumn('PublisherName');
     $c->addAscendingOrderByColumn(BookTableMap::COL_TITLE);
     $c->setOffset(20);
     $c->setLimit(20);
     $params = array();
     $expectedSql = "SELECT [book.ID], [book.TITLE], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID) DESC, book.TITLE ASC) AS [RowNumber], book.ID AS [book.ID], book.TITLE AS [book.TITLE], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.ID)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40";
     $sql = $c->createSelectSql($params);
     $this->assertEquals($expectedSql, $sql);
 }
開發者ID:bondarovich,項目名稱:Propel2,代碼行數:21,代碼來源:TableMapTest.php


注:本文中的Propel\Runtime\ActiveQuery\Criteria::setOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。