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


PHP Criteria::addDescendingOrderByColumn方法代码示例

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


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

示例3: testMergeWithOrderByColumns

 public function testMergeWithOrderByColumns()
 {
     $c1 = new Criteria();
     $c1->addAscendingOrderByColumn(BookTableMap::COL_TITLE);
     $c1->addAscendingOrderByColumn(BookTableMap::COL_ID);
     $c2 = new Criteria();
     $c1->mergeWith($c2);
     $this->assertEquals(array(BookTableMap::COL_TITLE . ' ASC', BookTableMap::COL_ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not remove an existing orderby columns');
     $c1 = new Criteria();
     $c2 = new Criteria();
     $c2->addAscendingOrderByColumn(BookTableMap::COL_TITLE);
     $c2->addAscendingOrderByColumn(BookTableMap::COL_ID);
     $c1->mergeWith($c2);
     $this->assertEquals(array(BookTableMap::COL_TITLE . ' ASC', BookTableMap::COL_ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns to an empty order by');
     $c1 = new Criteria();
     $c1->addAscendingOrderByColumn(BookTableMap::COL_TITLE);
     $c2 = new Criteria();
     $c2->addAscendingOrderByColumn(BookTableMap::COL_ID);
     $c1->mergeWith($c2);
     $this->assertEquals(array(BookTableMap::COL_TITLE . ' ASC', BookTableMap::COL_ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns after the existing orderby columns');
     $c1 = new Criteria();
     $c1->addAscendingOrderByColumn(BookTableMap::COL_TITLE);
     $c2 = new Criteria();
     $c2->addAscendingOrderByColumn(BookTableMap::COL_TITLE);
     $c1->mergeWith($c2);
     $this->assertEquals(array(BookTableMap::COL_TITLE . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not merge duplicated orderby columns');
     $c1 = new Criteria();
     $c1->addAscendingOrderByColumn(BookTableMap::COL_TITLE);
     $c2 = new Criteria();
     $c2->addDescendingOrderByColumn(BookTableMap::COL_TITLE);
     $c1->mergeWith($c2);
     $this->assertEquals(array(BookTableMap::COL_TITLE . ' ASC', BookTableMap::COL_TITLE . ' DESC'), $c1->getOrderByColumns(), 'mergeWith() merges duplicated orderby columns with inverse direction');
 }
开发者ID:bondarovich,项目名称:Propel2,代码行数:33,代码来源:CriteriaMergeTest.php

示例4: queryOrderItemsStateHistoriesOrderedByNewestState

 /**
  * @api
  *
  * @param \Propel\Runtime\Collection\ObjectCollection $salesOrderItems
  *
  * @return void
  */
 public function queryOrderItemsStateHistoriesOrderedByNewestState(ObjectCollection $salesOrderItems)
 {
     foreach ($salesOrderItems as $orderItemEntity) {
         $criteria = new Criteria();
         $criteria->addDescendingOrderByColumn(SpyOmsOrderItemStateHistoryTableMap::COL_ID_OMS_ORDER_ITEM_STATE_HISTORY);
         $orderItemEntity->getStateHistoriesJoinState($criteria);
         $orderItemEntity->resetPartialStateHistories(false);
     }
 }
开发者ID:spryker,项目名称:Sales,代码行数:16,代码来源:SalesQueryContainer.php


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