Ejemplo n.º 1
0
 /**
  * This method selects all DataTables that have the name $name over the period.
  * It calls the appropriate methods that sum all these tables together.
  * The resulting DataTable is returned.
  *
  * @param string $name
  * @param array $invalidSummedColumnNameToRenamedName  columns in the array (old name, new name) to be renamed as the sum operation is not valid on them (eg. nb_uniq_visitors->sum_daily_nb_uniq_visitors)
  * @param array $columnAggregationOperations           Operations for aggregating columns, @see Piwik_DataTable_Row::sumRow()
  * @return Piwik_DataTable
  */
 protected function getRecordDataTableSum($name, $invalidSummedColumnNameToRenamedName, &$columnAggregationOperations = null)
 {
     $table = new Piwik_DataTable();
     if (is_array($columnAggregationOperations)) {
         $table->setColumnAggregationOperations($columnAggregationOperations);
     }
     foreach ($this->archives as $archive) {
         $archive->preFetchBlob($name);
         $datatableToSum = $archive->getDataTable($name);
         $archive->loadSubDataTables($name, $datatableToSum);
         $table->addDataTable($datatableToSum);
         $archive->freeBlob($name);
     }
     if (is_null($invalidSummedColumnNameToRenamedName)) {
         $invalidSummedColumnNameToRenamedName = self::$invalidSummedColumnNameToRenamedName;
     }
     foreach ($invalidSummedColumnNameToRenamedName as $oldName => $newName) {
         $table->renameColumn($oldName, $newName);
     }
     return $table;
 }