/** * 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); } }
/** * 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; }
/** * 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; }
function fill(SelectQuery $selectQuery, EntityQueryBuilder $entityQueryBuilder) { $selectQuery->setDistinct(); }