Sums a DataTable to all the tables in this array.

_Note: Will only add `$tableToSum` if the childTable has some rows._

See {@link Piwik\DataTable::addDataTable()}.

@param DataTable $tableToSum
559282
public function addDataTable(DataTable $tableToSum)
    {
        foreach ($this->getDataTables() as $childTable) {
            $childTable->addDataTable($tableToSum);
        }
    }
120247
def +(table)
      t2 = table.to_a
      t2_header = t2.shift
      raise 'Tables cannot be added due to header mismatch' unless @column_properties.keys == t2_header
      raise 'Tables cannot be added due to column properties mismatch' unless column_properties_eql? table.column_properties
      raise 'Tables cannot be added due to table properties mismatch' unless @table_properties.to_h == table.table_properties.to_h
      TableTransform::Table.new(self.to_a + t2)
    end
541417
protected function addIndexes(Table $table)
    {
        $dataFetcher = $this->dbh->query("sp_indexes_rowset '" . $table->getName() . "'");
        $dataFetcher->setStyle(\PDO::FETCH_ASSOC);

        $indexes = [];
        foreach ($dataFetcher as $row) {
            $colName = $this->cleanDelimitedIdentifiers($row['COLUMN_NAME']);
            $name = $this->cleanDelimitedIdentifiers($row['INDEX_NAME']);

            $isPk = $this->cleanDelimitedIdentifiers($row['PRIMARY_KEY']);
            $isUnique = $this->cleanDelimitedIdentifiers($row['UNIQUE']);

            $localColumn   = $table->getColumn($colName);

            // ignore PRIMARY index
            if ($isPk) {
                continue;
            }

            if (!isset($indexes[$name])) {
                if ($isUnique) {
                    $indexes[$name] = new Unique($name);
                } else {
                    $indexes[$name] = new Index($name);
                }
                $indexes[$name]->setTable($table);
            }

            $indexes[$name]->addColumn($localColumn);
        }

        foreach ($indexes as $index) {
            if ($index instanceof Unique) {
                $table->addUnique($index);
            } else {
                $table->addIndex($index);
            }
        }
    }
181718
public function tableColumns($tableColumns = null)
    {
        if ($tableColumns === null)
        {
            return $this->_tableColumns;
        }
        $this->_tableColumns = $tableColumns;

        return $this;
    }
693399
public function moveY(TcTable $table) {
        $y = 0.6 / $table->getPdf()->getScaleFactor();
        $table->getPdf()->SetY($table->getPdf()->GetY() + $y);
    }
47103
public function addTable($table)
    {
        $this->nextTableId++;
        $this[$this->nextTableId] = $table;
        return $this->nextTableId;
    }
677753
public function setColumnsSummary(array $columns, $rowCallback = null)
	{
		if ($this->hasSomeAggregationFunction()) {
			throw new DataGridException('You can use either ColumnsSummary or AggregationFunctions');
		}

		if (!empty($rowCallback)) {
			if (!is_callable($rowCallback)) {
				throw new \InvalidArgumentException('Row summary callback must be callable');
			}
		}

		$this->columnsSummary = new ColumnsSummary($this, $columns, $rowCallback);

		return $this->columnsSummary;
	}
30480
public function update($dataItem)
    {
        /** @var DataItem $dataItem */
        $dataItem   = $this->create($dataItem);
        $data       = $this->cleanData($dataItem->toArray());
        $connection = $this->getConnection();
        unset($data[ $this->getUniqueId() ]);

        if (empty($data)) {
            throw new \Exception("DataItem can't be updated without criteria");
        }

        $connection->update($this->tableName, $data, array($this->uniqueId => $dataItem->getId()));
        return $dataItem;
    }
1311081
public function filter($table)
    {
        $row = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
        if ($row) {
            $row->setColumn('label', $this->newLabel);
        } else {
            $row = $table->getRowFromLabel(DataTable::LABEL_SUMMARY_ROW);
            if ($row) {
                $row->setColumn('label', $this->newLabel);
            }
        }

        // recurse
        foreach ($table->getRowsWithoutSummaryRow() as $row) {
            $subTable = $row->getSubtable();
            if ($subTable) {
                $this->filter($subTable);
            }
        }
        
       
        $summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
        if (!empty($summaryRow)) {
            $subTable = $summaryRow->getSubtable();
            if ($subTable) {
                $this->filter($subTable);
            }
        }
    }
160789
public function addColumn($data)
    {
        if ($data instanceof Column) {
            $column = $data;
            $this->columns[] = $column->getName();
            if ($column->getSize()) {
                $this->columnsSize[$column->getName()] = $column->getSize();
            }
            $this->columnObjects[] = $column;
        } else {
            $this->columns[] = $name = $data['name'];
            if (isset($data['size']) && $data['size'] > 0) {
                $this->columnsSize[$name] = $data['size'];
            }
            if ($this->getTable()) {
                $this->columnObjects[] = $this->getTable()->getColumn($name);
            }
        }
    }
1259666
public function sort(DataTable $table)
    {
        // all that code is in here and not in separate methods for best performance. It does make a difference once
        // php has to copy many (eg 50k) rows otherwise.

        $table->setTableSortedBy($this->config->primaryColumnToSort);

        $rows = $table->getRowsWithoutSummaryRow();

        // we need to sort rows that have a value separately from rows that do not have a value since we always want
        // to append rows that do not have a value at the end.
        $rowsWithValues    = array();
        $rowsWithoutValues = array();

        $valuesToSort = array();
        foreach ($rows as $key => $row) {
            $value = $this->getColumnValue($row);
            if (isset($value)) {
                $valuesToSort[] = $value;
                $rowsWithValues[] = $row;
            } else {
                $rowsWithoutValues[] = $row;
            }
        }

        unset($rows);

        if ($this->config->isSecondaryColumnSortEnabled && $this->config->secondaryColumnToSort) {
            $secondaryValues = array();
            foreach ($rowsWithValues as $key => $row) {
                $secondaryValues[$key] = $row->getColumn($this->config->secondaryColumnToSort);
            }

            array_multisort($valuesToSort, $this->config->primarySortOrder, $this->config->primarySortFlags, $secondaryValues, $this->config->secondarySortOrder, $this->config->secondarySortFlags, $rowsWithValues);

        } else {
            array_multisort($valuesToSort, $this->config->primarySortOrder, $this->config->primarySortFlags, $rowsWithValues);
        }

        if (!empty($rowsWithoutValues) && $this->config->secondaryColumnToSort) {
            $secondaryValues = array();
            foreach ($rowsWithoutValues as $key => $row) {
                $secondaryValues[$key] = $row->getColumn($this->config->secondaryColumnToSort);
            }

            array_multisort($secondaryValues, $this->config->secondarySortOrder, $this->config->secondarySortFlags, $rowsWithoutValues);
        }

        unset($secondaryValues);

        foreach ($rowsWithoutValues as $row) {
            $rowsWithValues[] = $row;
        }

        $table->setRows(array_values($rowsWithValues));
    }
690049
public function setTotalDiscount($dDiscount)
    {
        $this->_oTotalDiscount = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $this->_oTotalDiscount->setBruttoPriceMode();
        $this->_oTotalDiscount->add($dDiscount);
    }
651328
public function addTable(TableInterface $table)
    {
        $table->setSchema($this);
        $this->_tables[$table->getName()] = $table;
        return $this;
    }
1168080
public function filter($table)
    {
        // set of all column names in the pivoted table mapped with the sum of all column
        // values. used later in truncating and ordering the pivoted table's columns.
        $columnSet = array();

        // if no pivot column was set, use the first one found in the row
        if (empty($this->pivotColumn)) {
            $this->pivotColumn = $this->getNameOfFirstNonLabelColumnInTable($table);
        }

        Log::debug("PivotByDimension::%s: pivoting table with pivot column = %s", __FUNCTION__, $this->pivotColumn);

        foreach ($table->getRows() as $row) {
            $row->setColumns(array('label' => $row->getColumn('label')));

            $associatedTable = $this->getIntersectedTable($table, $row);
            if (!empty($associatedTable)) {
                foreach ($associatedTable->getRows() as $columnRow) {
                    $pivotTableColumn = $columnRow->getColumn('label');

                    $columnValue = $this->getColumnValue($columnRow, $this->pivotColumn);

                    if (isset($columnSet[$pivotTableColumn])) {
                        $columnSet[$pivotTableColumn] += $columnValue;
                    } else {
                        $columnSet[$pivotTableColumn] = $columnValue;
                    }

                    $row->setColumn($pivotTableColumn, $columnValue);
                }

                Common::destroy($associatedTable);
                unset($associatedTable);
            }
        }

        Log::debug("PivotByDimension::%s: pivoted columns set: %s", __FUNCTION__, $columnSet);

        $others = Piwik::translate('General_Others');
        $defaultRow = $this->getPivotTableDefaultRowFromColumnSummary($columnSet, $others);

        Log::debug("PivotByDimension::%s: un-prepended default row: %s", __FUNCTION__, $defaultRow);

        // post process pivoted datatable
        foreach ($table->getRows() as $row) {
            // remove subtables from rows
            $row->removeSubtable();
            $row->deleteMetadata('idsubdatatable_in_db');

            // use default row to ensure column ordering and add missing columns/aggregate cut-off columns
            $orderedColumns = $defaultRow;
            foreach ($row->getColumns() as $name => $value) {
                if (isset($orderedColumns[$name])) {
                    $orderedColumns[$name] = $value;
                } else {
                    $orderedColumns[$others] += $value;
                }
            }
            $row->setColumns($orderedColumns);
        }

        $table->clearQueuedFilters(); // TODO: shouldn't clear queued filters, but we can't wait for them to be run
                                      //       since generic filters are run before them. remove after refactoring
                                      //       processed metrics.

        // prepend numerals to columns in a queued filter (this way, disable_queued_filters can be used
        // to get machine readable data from the API if needed)
        $prependedColumnNames = $this->getOrderedColumnsWithPrependedNumerals($defaultRow, $others);

        Log::debug("PivotByDimension::%s: prepended column name mapping: %s", __FUNCTION__, $prependedColumnNames);

        $table->queueFilter(function (DataTable $table) use ($prependedColumnNames) {
            foreach ($table->getRows() as $row) {
                $row->setColumns(array_combine($prependedColumnNames, $row->getColumns()));
            }
        });
    }
1009221
protected function manipulateDataTable($dataTable)
    {
        $result = $dataTable->getEmptyClone();
        foreach ($this->labels as $labelIndex => $label) {
            $row = null;
            foreach ($this->getLabelVariations($label) as $labelVariation) {
                $labelVariation = explode(self::SEPARATOR_RECURSIVE_LABEL, $labelVariation);

                $row = $this->doFilterRecursiveDescend($labelVariation, $dataTable);
                if ($row) {
                    if ($this->addLabelIndex) {
                        $row->setMetadata(self::FLAG_IS_ROW_EVOLUTION, $labelIndex);
                    }
                    $result->addRow($row);
                    break;
                }
            }
        }
        return $result;
    }
1117624
protected function addColumns(\MUtil_Html_TableElement $table)
    {
        $table->addColumn(
                array(\MUtil_Html::raw($this->repeater->key), 'class' => $this->repeater->class),
                $this->_('Question code')
                );
        $table->addColumn(
                array(\MUtil_Html::raw($this->repeater->question), 'class' => $this->repeater->class),
                $this->_('Question')
                );
        $table->addColumn(
                $this->repeater->answers->call($this, 'showAnswers', $this->repeater->answers),
                $this->_('Answer options')
                );
        // $table->addColumn($this->repeater->type, 'Type');
    }
1062515
public function addChange($table, $method, $data)
    {
        $table = $this->getRawTableName($table);

        if (!isset($this->changes[$table])) {
            $this->changes[$table] = [];
        }

        $this->changes[$table][] = new TableChange([
            'schema' => TableStructure::identifySchema(get_class($this->db->schema)),
            'table' => $table,
            'method' => $method,
            'data' => $data,
        ]);
    }