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


PHP SelectQuery::addDerivedTable方法代码示例

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


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


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