public static function makeFromIndexedArray($array, $subtablePerLabel = null)
{
$table = new DataTable();
foreach ($array as $label => $row) {
$cleanRow = array();
// Support the case of an $array of single values
if (!is_array($row)) {
$row = array('value' => $row);
}
// Put the 'label' column first
$cleanRow[Row::COLUMNS] = array('label' => $label) + $row;
// Assign subtable if specified
if (isset($subtablePerLabel[$label])) {
$cleanRow[Row::DATATABLE_ASSOCIATED] = $subtablePerLabel[$label];
}
$table->addRow(new Row($cleanRow));
}
return $table;
}
protected function aggregateByPlugin() { $selects = array("sum(case log_visit.config_pdf when 1 then 1 else 0 end) as pdf", "sum(case log_visit.config_flash when 1 then 1 else 0 end) as flash", "sum(case log_visit.config_java when 1 then 1 else 0 end) as java", "sum(case log_visit.config_director when 1 then 1 else 0 end) as director", "sum(case log_visit.config_quicktime when 1 then 1 else 0 end) as quicktime", "sum(case log_visit.config_realplayer when 1 then 1 else 0 end) as realplayer", "sum(case log_visit.config_windowsmedia when 1 then 1 else 0 end) as windowsmedia", "sum(case log_visit.config_gears when 1 then 1 else 0 end) as gears", "sum(case log_visit.config_silverlight when 1 then 1 else 0 end) as silverlight", "sum(case log_visit.config_cookie when 1 then 1 else 0 end) as cookie"); $query = $this->getLogAggregator()->queryVisitsByDimension(array(), false, $selects, $metrics = array()); $data = $query->fetch(); $cleanRow = LogAggregator::makeArrayOneColumn($data, Metrics::INDEX_NB_VISITS); $table = DataTable::makeFromIndexedArray($cleanRow); $this->insertTable(self::PLUGIN_RECORD_NAME, $table); }