Piwik\DataTable::addDataTable PHP Метод

addDataTable() публичный Метод

This method will sum rows that have the same label. If a row is found in $tableToSum whose label is not found in $this, the row will be added to $this. If the subtables for this table are loaded, they will be summed as well. Rows are summed together by summing individual columns. By default columns are summed by adding one column value to another. Some columns cannot be aggregated this way. In these cases, the {@link COLUMN_AGGREGATION_OPS_METADATA_NAME} metadata can be used to specify a different type of operation.
public addDataTable ( DataTable $tableToSum )
$tableToSum DataTable
    public function addDataTable(DataTable $tableToSum)
    {
        if ($tableToSum instanceof Simple) {
            if ($tableToSum->getRowsCount() > 1) {
                throw new Exception("Did not expect a Simple table with more than one row in addDataTable()");
            }
            $row = $tableToSum->getFirstRow();
            $this->aggregateRowFromSimpleTable($row);
        } else {
            $columnAggregationOps = $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
            foreach ($tableToSum->getRowsWithoutSummaryRow() as $row) {
                $this->aggregateRowWithLabel($row, $columnAggregationOps);
            }
            // we do not use getRows() as this method might get called 100k times when aggregating many datatables and
            // this takes a lot of time.
            $row = $tableToSum->getRowFromId(DataTable::ID_SUMMARY_ROW);
            if ($row) {
                $this->aggregateRowWithLabel($row, $columnAggregationOps);
            }
        }
    }

Usage Example

Пример #1
0
 protected function getOverviewFromGoalTables($tableByGoal)
 {
     $overview = new DataTable();
     foreach ($tableByGoal as $idGoal => $table) {
         if ($this->isStandardGoal($idGoal)) {
             $overview->addDataTable($table);
         }
     }
     return $overview;
 }
All Usage Examples Of Piwik\DataTable::addDataTable