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


PHP SelectQuery::setDistinct方法代码示例

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


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

示例1: loadNext

 /**
  * Load the next bunch of items
  * 
  * @return void
  * @access public
  * @since 3/1/06
  */
 function loadNext()
 {
     $dbc = Services::getService("DatabaseManager");
     // get the list of the next set of Ids
     $query = new SelectQuery();
     $query->addTable("log_entry");
     $query->addColumn("id", "entry_id", "log_entry");
     $query->setDistinct(true);
     $query->addOrderBy("timestamp", DESCENDING);
     $this->addWhereClauses($query);
     $query->limitNumberOfRows($this->_numPerLoad);
     if ($this->_currentRow) {
         $query->startFromRow($this->_currentRow + 1);
     }
     // 		printpre('CurrentRow at load: '.$this->_currentRow);
     // 		printpre($query->asString());
     $results = $dbc->query($query, $this->_dbIndex);
     $nextIds = array();
     while ($results->hasNext()) {
         $row = $results->next();
         $nextIds[] = $row['entry_id'];
     }
     // 		printpre($nextIds);
     /*********************************************************
      * Load the rows for the next set of Ids
      *********************************************************/
     $query = new SelectQuery();
     $query->addTable("log_entry");
     $query->addColumn("id", "id", "log_entry");
     $query->addColumn("timestamp", "timestamp", "log_entry");
     $query->addColumn("category", "category", "log_entry");
     $query->addColumn("description", "description", "log_entry");
     $query->addColumn("backtrace", "backtrace", "log_entry");
     $subQuery = new SelectQuery();
     $subQuery->addColumn("*");
     $subQuery->addTable("log_agent");
     $subQuery->addWhereIn("fk_entry", $nextIds);
     $query->addDerivedTable($subQuery, LEFT_JOIN, "log_entry.id = tmp_agent.fk_entry", "tmp_agent");
     $query->addColumn("fk_agent", "agent_id", "tmp_agent");
     $subQuery = new SelectQuery();
     $subQuery->addColumn("*");
     $subQuery->addTable("log_node");
     $subQuery->addWhereIn("fk_entry", $nextIds);
     $query->addDerivedTable($subQuery, LEFT_JOIN, "log_entry.id = tmp_node.fk_entry", "tmp_node");
     $query->addColumn("fk_node", "node_id", "tmp_node");
     $query->addWhereIn("id", $nextIds);
     $query->addOrderBy("timestamp", DESCENDING);
     $query->addOrderBy("id", ASCENDING);
     //  		printpre($query->asString());
     $results = $dbc->query($query, $this->_dbIndex);
     $i = $this->_current;
     $currentEntryId = null;
     $timestamp = null;
     $category = null;
     $description = null;
     $backtrace = '';
     $agents = array();
     $nodes = array();
     while ($results->hasNext()) {
         $row = $results->next();
         // Create the entry if we have all of the data for it.
         if ($currentEntryId && $currentEntryId != $row["id"]) {
             // 				printpre("Creating Entry: ".$currentEntryId." ".$timestamp." -- ".($i+1)." of ".$this->_count);
             $this->_entries[$i] = new HarmoniEntry($dbc->fromDBDate($timestamp, $this->_dbIndex), $category, $description, $backtrace, array_unique($agents), array_unique($nodes), $this->_formatType, $this->_priorityType);
             $i++;
             $this->_currentRow++;
             $currentEntryId = null;
             $timestamp = null;
             $category = null;
             $description = null;
             $backtrace = '';
             $agents = array();
             $nodes = array();
         }
         $currentEntryId = $row["id"];
         $timestamp = $row["timestamp"];
         $category = $row["category"];
         $description = $row["description"];
         $backtrace = $row["backtrace"];
         $agents[] = $row["agent_id"];
         $nodes[] = $row["node_id"];
         // 			printpre($currentEntryId." ".$timestamp." ".$this->_currentRow);
     }
     $results->free();
     // get the last entry if we are at the end of the iterator
     if ($currentEntryId && $i == $this->_count - 1) {
         // 			printpre("Creating Entry: ".$currentEntryId." ".$timestamp." -- ".($i+1)." of ".$this->_count);
         $this->_entries[$i] = new HarmoniEntry($dbc->fromDBDate($timestamp, $this->_dbIndex), $category, $description, $backtrace, array_unique($agents), array_unique($nodes), $this->_formatType, $this->_priorityType);
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:97,代码来源:HarmoniEntryIterator.class.php

示例2: getLogNamesForWriting

 /**
  * Return the names of writable Logs.
  *	
  * @return object StringIterator
  * 
  * @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 getLogNamesForWriting()
 {
     $dbc = Services::getService("DatabaseManager");
     $query = new SelectQuery();
     $query->addColumn("log_name");
     $query->addTable("log_entry");
     $query->setDistinct(true);
     $query->addOrderBy("log_name");
     $results = $dbc->query($query, $this->_dbIndex);
     $names = array();
     while ($results->hasNext()) {
         $names[] = $results->field("log_name");
         $results->advanceRow();
     }
     $results->free();
     $iterator = new HarmoniIterator($names);
     return $iterator;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:36,代码来源:HarmoniLoggingManager.class.php

示例3: getNodeTypes

 /**
  * Get all NodeTypes used in this Hierarchy.
  *	
  * @return object TypeIterator
  * 
  * @throws object HierarchyException An exception with one of
  *		   the following messages defined in
  *		   org.osid.hierarchy.HierarchyException may be thrown:	 {@link
  *		   org.osid.hierarchy.HierarchyException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.hierarchy.HierarchyException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.hierarchy.HierarchyException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.hierarchy.HierarchyException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}
  * 
  * @access public
  */
 function getNodeTypes()
 {
     $dbHandler = Services::getService("DatabaseManager");
     $query = new SelectQuery();
     // set the tables
     $query->addTable("az2_node");
     $joinc = "az2_node.fk_type = az2_node_type.id";
     $query->addTable("az2_node_type", INNER_JOIN, $joinc);
     $hierarchyIdValue = $this->_id->getIdString();
     $query->addWhereEqual("az2_node.fk_hierarchy", $hierarchyIdValue);
     // set the columns to select
     $query->setDistinct(true);
     $query->addColumn("id", "id", "az2_node_type");
     $query->addColumn("domain", "domain", "az2_node_type");
     $query->addColumn("authority", "authority", "az2_node_type");
     $query->addColumn("keyword", "keyword", "az2_node_type");
     $query->addColumn("description", "description", "az2_node_type");
     $queryResult = $dbHandler->query($query, $this->_cache->_dbIndex);
     $types = array();
     while ($queryResult->hasMoreRows()) {
         // fetch current row
         $arr = $queryResult->getCurrentRow();
         // create type object
         $type = new HarmoniType($arr['domain'], $arr['authority'], $arr['keyword'], $arr['description']);
         // add it to array
         $types[] = $type;
         $queryResult->advanceRow();
     }
     $queryResult->free();
     $result = new HarmoniTypeIterator($types);
     return $result;
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:51,代码来源:Hierarchy.class.php

示例4: fill

 function fill(SelectQuery $selectQuery, EntityQueryBuilder $entityQueryBuilder)
 {
     $selectQuery->setDistinct();
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:4,代码来源:DistinctProjection.class.php


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