本文整理汇总了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);
}
}