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


PHP SQLSelect::addOrderBy方法代码示例

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


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

示例1: augmentSQL

 /**
  * Update any requests to limit the results to the current site
  */
 public function augmentSQL(SQLSelect $query)
 {
     if (Subsite::$disable_subsite_filter) {
         return;
     }
     // If you're querying by ID, ignore the sub-site - this is a bit ugly... (but it was WAYYYYYYYYY worse)
     //@TODO I don't think excluding if SiteTree_ImageTracking is a good idea however because of the SS 3.0 api and ManyManyList::removeAll() changing the from table after this function is called there isn't much of a choice
     $from = $query->getFrom();
     if (isset($from['SiteTree_ImageTracking']) || $query->filtersOnID()) {
         return;
     }
     $subsiteID = (int) Subsite::currentSubsiteID();
     // The foreach is an ugly way of getting the first key :-)
     foreach ($query->getFrom() as $tableName => $info) {
         $where = "\"{$tableName}\".\"SubsiteID\" IN (0, {$subsiteID})";
         $query->addWhere($where);
         break;
     }
     $sect = array_values($query->getSelect());
     $isCounting = strpos($sect[0], 'COUNT') !== false;
     // Ordering when deleting or counting doesn't apply
     if (!$isCounting) {
         $query->addOrderBy("\"SubsiteID\"");
     }
 }
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:28,代码来源:FileSubsites.php

示例2: sort

 /**
  * Set the ORDER BY clause of this query
  *
  * @see SQLSelect::orderby()
  *
  * @param String $sort Column to sort on (escaped SQL statement)
  * @param String $direction Direction ("ASC" or "DESC", escaped SQL statement)
  * @param Boolean $clear Clear existing values
  * @return DataQuery
  */
 public function sort($sort = null, $direction = null, $clear = true)
 {
     if ($clear) {
         $this->query->setOrderBy($sort, $direction);
     } else {
         $this->query->addOrderBy($sort, $direction);
     }
     return $this;
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:19,代码来源:DataQuery.php


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