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


PHP Doctrine_Query::orderby方法代码示例

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


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

示例1: testGetLimitSubqueryWithOrderByOnAggregateValuesAndColumns

 public function testGetLimitSubqueryWithOrderByOnAggregateValuesAndColumns()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, COUNT(DISTINCT a.id) num_albums');
     $q->from('User u, u.Album a');
     $q->orderby('num_albums, u.name');
     $q->groupby('u.id');
     $q->limit(5);
     $q->execute();
     $this->assertEqual($this->dbh->pop(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(DISTINCT a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.id IN (SELECT doctrine_subquery_alias.id FROM (SELECT DISTINCT e2.id, COUNT(DISTINCT a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a2__0, e2.name LIMIT 5) AS doctrine_subquery_alias) AND (e.type = 0) GROUP BY e.id ORDER BY a__0, e.name');
 }
开发者ID:ninjapenguin,项目名称:kohana-Doctrine-module,代码行数:11,代码来源:PgsqlSubqueryTestCase.php

示例2: testGetLimitSubquerySupportsOrderByAndHavingWithAggregateValues

 public function testGetLimitSubquerySupportsOrderByAndHavingWithAggregateValues()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, COUNT(DISTINCT a.id) num_albums');
     $q->from('User u, u.Album a');
     $q->orderby('num_albums DESC');
     $q->having('num_albums > 0');
     $q->groupby('u.id');
     $q->limit(5);
     $q->execute();
     $this->dbh->pop();
     $this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(DISTINCT a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id HAVING a2__0 > 0 ORDER BY a2__0 DESC LIMIT 5');
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:13,代码来源:MysqlSubqueryTestCase.php

示例3: testSelfReferencingWithNestedOrderBy

 public function testSelfReferencingWithNestedOrderBy()
 {
     $query = new Doctrine_Query();
     $query->from('Forum_Category.Subcategory.Subcategory');
     $query->orderby('Forum_Category.id ASC, Forum_Category.Subcategory.name DESC');
     $coll = $query->execute();
     $category = $coll[0];
     $this->assertEqual($category->name, 'Root');
     $this->assertEqual($category->Subcategory[0]->name, 'Sub 2');
     $this->assertEqual($category->Subcategory[1]->name, 'Sub 1');
     $this->assertEqual($category->Subcategory[1]->Subcategory[0]->name, 'Sub 1 Sub 1');
     $this->assertEqual($category->Subcategory[1]->Subcategory[1]->name, 'Sub 1 Sub 2');
     $this->assertEqual($category->Subcategory[0]->Subcategory[0]->name, 'Sub 2 Sub 1');
     $this->assertEqual($category->Subcategory[0]->Subcategory[1]->name, 'Sub 2 Sub 2');
     $this->connection->clear();
 }
开发者ID:swk,项目名称:bluebox,代码行数:16,代码来源:ReferenceModelTestCase.php

示例4: testGetLimitSubqueryOrderBy2

 public function testGetLimitSubqueryOrderBy2()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, COUNT(DISTINCT a.id) num_albums');
     $q->from('User u, u.Album a');
     $q->orderby('num_albums');
     $q->groupby('u.id');
     try {
         // this causes getLimitSubquery() to be used, and it fails
         $q->limit(5);
         $users = $q->execute();
         $count = $users->count();
     } catch (Doctrine_Exception $e) {
         $this->fail();
     }
     $this->assertEqual($q->getSql(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(DISTINCT a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a__0 LIMIT 5) AND (e.type = 0) GROUP BY e.id ORDER BY a__0');
 }
开发者ID:ninjapenguin,项目名称:kohana-Doctrine-module,代码行数:17,代码来源:SubqueryTestCase.php

示例5: setOrderBy

 /**
  * @return
  */
 protected function setOrderBy()
 {
     if ($this->_orderby_run) {
         return;
     }
     switch ($this->_order_by) {
         case 'slice_title':
         case 'slice_filesize':
         case 'slice_xsize':
         case 'slice_ysize':
         case 'slice_updated_at':
         case 'slice_created_at':
             $this->_query->orderBy('s.' . str_replace('slice_', '', $this->_order_by) . ' ' . $this->_order_direction);
             break;
         case 'file_title':
         case 'file_filesize':
         case 'file_xsize':
         case 'file_ysize':
         case 'file_updated_at':
         case 'file_created_at':
             $this->_query->leftJoin('s.File f');
             $this->_query->orderBy('f.' . str_replace('file_', '', $this->_order_by) . ' ' . $this->_order_direction);
             break;
         case 'views':
             $this->_query->leftJoin('s.File f');
             $this->_query->leftJoin('f.Views v');
             $this->_query->orderBy('v.count ' . $this->_order_direction);
             break;
         case 'loves':
             $this->_query->leftJoin('s.File f');
             $this->_query->leftJoin('f.Loves l');
             $this->_query->orderBy('l.count ' . $this->_order_direction);
             break;
         case 'random':
             $this->_query->select('s.*, RANDOM() as rand');
             $this->_query->orderby('rand');
             break;
         case 'gallery_ordering':
             $this->_query->orderBy('s.ordering');
     }
     $this->_orderby_run = true;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:45,代码来源:GalleryFilter.php

示例6: testOrderByExpression

 public function testOrderByExpression()
 {
     $query = new Doctrine_Query();
     $query->select('u.*, (u.id * u.id) multiplication');
     $query->from('User u');
     $query->orderby('multiplication asc');
     try {
         $users = $query->execute();
         $this->pass();
     } catch (Exception $e) {
         $this->fail();
     }
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:13,代码来源:SelectExpressionTestCase.php


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