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


PHP Varien_Data_Collection_Db::setOrder方法代码示例

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


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

示例1: testSetAddOrder

 /**
  * @return PHPUnit_Framework_MockObject_MockObject|Zend_Db_Adapter_Abstract
  */
 public function testSetAddOrder()
 {
     $adapter = $this->_getAdapterMock('Zend_Db_Adapter_Pdo_Mysql', array('fetchAll'), null);
     $this->_collection->setConnection($adapter);
     $select = $this->_collection->getSelect();
     $this->assertEmpty($select->getPart(Zend_Db_Select::ORDER));
     $this->_collection->addOrder('some_field', Varien_Data_Collection::SORT_ORDER_ASC);
     $this->_collection->setOrder('other_field', Varien_Data_Collection::SORT_ORDER_ASC);
     $this->_collection->addOrder('other_field', Varien_Data_Collection::SORT_ORDER_DESC);
     $this->_collection->load();
     $selectOrders = $select->getPart(Zend_Db_Select::ORDER);
     $this->assertEquals('some_field ASC', (string) array_shift($selectOrders));
     $this->assertEquals('other_field DESC', (string) array_shift($selectOrders));
     $this->assertEmpty(array_shift($selectOrders));
     return $adapter;
 }
开发者ID:relue,项目名称:magento2,代码行数:19,代码来源:DbTest.php

示例2: testSetAddOrder

 /**
  * @return PHPUnit_Framework_MockObject_MockObject|Zend_Db_Adapter_Abstract
  */
 public function testSetAddOrder()
 {
     $adapter = $this->_getAdapterMock('Zend_Db_Adapter_Pdo_Mysql', array('fetchAll'), null);
     $this->_collection->setConnection($adapter);
     $select = $this->_collection->getSelect();
     $this->assertEmpty($select->getPart(Zend_Db_Select::ORDER));
     /* Direct access to select object is available and many places are using it for sort order declaration */
     $select->order('select_field', Varien_Data_Collection::SORT_ORDER_ASC);
     $this->_collection->addOrder('some_field', Varien_Data_Collection::SORT_ORDER_ASC);
     $this->_collection->setOrder('other_field', Varien_Data_Collection::SORT_ORDER_ASC);
     $this->_collection->addOrder('other_field', Varien_Data_Collection::SORT_ORDER_DESC);
     $this->_collection->load();
     $selectOrders = $select->getPart(Zend_Db_Select::ORDER);
     $this->assertEquals(array('select_field', 'ASC'), array_shift($selectOrders));
     $this->assertEquals('some_field ASC', (string) array_shift($selectOrders));
     $this->assertEquals('other_field DESC', (string) array_shift($selectOrders));
     $this->assertEmpty(array_shift($selectOrders));
     return $adapter;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:22,代码来源:DbTest.php

示例3: _applyCollectionModifiers

 /**
  * Set navigation parameters and apply filters from URL params
  *
  * @param Varien_Data_Collection_Db $collection
  * @return Mage_Api2_Model_Resource
  */
 protected final function _applyCollectionModifiers(Varien_Data_Collection_Db $collection)
 {
     $pageNumber = $this->getRequest()->getPageNumber();
     if ($pageNumber != abs($pageNumber)) {
         $this->_critical(self::RESOURCE_COLLECTION_PAGING_ERROR);
     }
     $pageSize = $this->getRequest()->getPageSize();
     if (null == $pageSize) {
         $pageSize = self::PAGE_SIZE_DEFAULT;
     } else {
         if ($pageSize != abs($pageSize) || $pageSize > self::PAGE_SIZE_MAX) {
             $this->_critical(self::RESOURCE_COLLECTION_PAGING_LIMIT_ERROR);
         }
     }
     $orderField = $this->getRequest()->getOrderField();
     if (null !== $orderField) {
         $operation = Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ;
         if (!is_string($orderField) || !array_key_exists($orderField, $this->getAvailableAttributes($this->getUserType(), $operation))) {
             $this->_critical(self::RESOURCE_COLLECTION_ORDERING_ERROR);
         }
         $collection->setOrder($orderField, $this->getRequest()->getOrderDirection());
     }
     $collection->setCurPage($pageNumber)->setPageSize($pageSize);
     return $this->_applyFilter($collection);
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:31,代码来源:Resource.php

示例4: setOrder

 /**
  * Set sorting order
  *
  * $attribute can also be an array of attributes
  *
  * @param string|array $attribute
  * @param string $dir
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 public function setOrder($attribute, $dir = self::SORT_ORDER_ASC)
 {
     if (is_array($attribute)) {
         foreach ($attribute as $attr) {
             parent::setOrder($attr, $dir);
         }
     }
     return parent::setOrder($attribute, $dir);
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:18,代码来源:Abstract.php


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