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


PHP SelectQuery::setGroupBy方法代码示例

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


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

示例1: getAgentIds

 /**
  * Answer agentIds that have stored tags
  * 
  * @return object IdIterator
  * @access public
  * @since 11/1/06
  */
 function getAgentIds()
 {
     $query = new SelectQuery();
     $query->addColumn('user_id');
     $query->addColumn('COUNT(user_id)', 'occurances');
     $query->addTable('tag');
     $query->setGroupBy(array('user_id'));
     $query->addOrderBy('occurances', DESCENDING);
     $dbc = Services::getService("DatabaseManager");
     $result = $dbc->query($query, $this->getDatabaseIndex());
     // Add tag objects to an array, still sorted by frequency of usage
     $agentIds = array();
     $idManager = Services::getService('Id');
     while ($result->hasNext()) {
         $row = $result->next();
         $agentIds[] = $idManager->getId($row['user_id']);
     }
     $iterator = new HarmoniIterator($agentIds);
     return $iterator;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:27,代码来源:TagManager.class.php

示例2: getPriorityTypes

 /**
  * Return the priority types available with this implementation.
  *	
  * @return object TypeIterator
  * 
  * @throws object LoggingException An exception with one of the
  *		   following messages defined in org.osid.logging.LoggingException
  *		   may be thrown:  {@link
  *		   org.osid.logging.LoggingException#UNIMPLEMENTED UNIMPLEMENTED},
  *		   {@link org.osid.logging.LoggingException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.logging.LoggingException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.logging.LoggingException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}
  * 
  * @access public
  */
 function getPriorityTypes()
 {
     $dbc = Services::getService("DatabaseManager");
     $query = new SelectQuery();
     $query->addColumn("domain", "domain", "log_type");
     $query->addColumn("authority", "authority", "log_type");
     $query->addColumn("keyword", "keyword", "log_type");
     $query->addColumn("description", "description", "log_type");
     $query->addTable("log_entry");
     $query->addTable("log_type", INNER_JOIN, "log_entry.fk_priority_type = log_type.id");
     $query->setGroupBy(array("log_type.id"));
     $query->addOrderBy("keyword");
     $results = $dbc->query($query, $this->_dbIndex);
     $types = array();
     // Add a custom type to encompass all priority types
     $types[] = new Type('logging', 'edu.middlebury', 'All', _('All priority types.'));
     while ($results->hasNext()) {
         $types[] = new Type($results->field("domain"), $results->field("authority"), $results->field("keyword"), $results->field("description"));
         $results->advanceRow();
     }
     $results->free();
     $iterator = new HarmoniIterator($types);
     return $iterator;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:42,代码来源:HarmoniLoggingManager.class.php

示例3: getItemsInSystem

 /**
  * Answer all items with this tag in a particular system
  * 
  * @return object ItemsIterator
  * @access public
  * @since 11/2/06
  */
 function getItemsInSystem($system)
 {
     $dbc = Services::getService("DatabaseManager");
     $subQuery = new SelectQuery();
     $subQuery->addColumn('tag_item.db_id');
     $subQuery->addColumn('tag_item.id');
     $subQuery->addColumn('tag_item.system');
     $subQuery->addColumn('tag.tstamp');
     $subQuery->addTable('tag');
     $subQuery->addTable('tag_item', INNER_JOIN, "tag.fk_item = tag_item.db_id");
     $subQuery->addWhere("tag.value='" . addslashes($this->getValue()) . "'");
     $subQuery->addWhere("tag_item.system='" . addslashes($system) . "'");
     $subQuery->addOrderBy('tag.tstamp', DESCENDING);
     $query = new SelectQuery();
     $query->addColumn('*');
     $query->addTable("(" . $dbc->generateSQL($subQuery, $this->getDatabaseIndex()) . ") AS tag_results");
     $query->setGroupBy(array('db_id'));
     $result = $dbc->query($query, $this->getDatabaseIndex());
     $iterator = new TaggedItemIterator($result);
     return $iterator;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:28,代码来源:Tag.class.php

示例4: getFunctionTypes

 /**
  * Get all the Function of the specified Type.
  * @param ref object functionType the Type of the Functions to return
  * @return ref object FunctionIterator
  */
 function getFunctionTypes()
 {
     if (!isset($this->_functionTypes)) {
         $dbHandler = Services::getService("DatabaseManager");
         $query = new SelectQuery();
         $query->addColumn("type_domain", "domain", "type");
         $query->addColumn("type_authority", "authority", "type");
         $query->addColumn("type_keyword", "keyword", "type");
         $query->addColumn("type_description", "type_description", "type");
         $query->addTable("az_function");
         $joinc = "fk_type = " . "type.type_id";
         $query->addTable("type", INNER_JOIN, $joinc);
         $query->setGroupBy(array("type_domain", "type_authority", "type_keyword", "type_description"));
         $queryResult = $dbHandler->query($query, $this->_dbIndex);
         $this->_functionTypes = array();
         while ($queryResult->hasMoreRows()) {
             $row = $queryResult->getCurrentRow();
             //			echo "<pre>";
             //			print_r($row);
             //			echo "</pre>";
             $this->_functionTypes[] = new HarmoniType($row['domain'], $row['authority'], $row['keyword'], $row['type_description']);
             $queryResult->advanceRow();
         }
         $queryResult->free();
     }
     $obj = new HarmoniTypeIterator($this->_functionTypes);
     return $obj;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:33,代码来源:AuthorizationCache.class.php


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