See {@link ColumnCallbackAddColumn}.

@param DataTable $table The table to filter.
354873
public function filter($table)
    {
        $columns = $this->columns;
        $functionParams  = $this->functionParameters;
        $functionToApply = $this->functionToApply;

        $extraProcessedMetrics = $table->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME);

        if (empty($extraProcessedMetrics)) {
            $extraProcessedMetrics = array();
        }

        $metric = new CallableProcessedMetric($this->columnToAdd, function (DataTable\Row $row) use ($columns, $functionParams, $functionToApply) {

            $columnValues = array();
            foreach ($columns as $column) {
                $columnValues[] = $row->getColumn($column);
            }

            $parameters = array_merge($columnValues, $functionParams);

            return call_user_func_array($functionToApply, $parameters);
        }, $columns);
        $extraProcessedMetrics[] = $metric;

        $table->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics);

        foreach ($table->getRows() as $row) {
            $row->setColumn($this->columnToAdd, $metric->compute($row));
            $this->filterSubTable($row);
        }
    }
958269
public function drop(string $table)
    {
        $compiler = $this->connection->schemaCompiler();

        $result = $compiler->drop($table);

        $this->connection->command($result['sql'], $result['params']);

        //clear table list
        $this->tableList = null;
        unset($this->columns[strtolower($table)]);
    }
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()));
            }
        });
    }
1112848
public function addColumn(Column $column)
    {
        $columns = func_get_args();

        foreach ($columns as $column) {
            $this->columns[$column->columnName] = $column;

            if ($column instanceof AutoIncrementColumn) {
                $this->uniqueIdentifierColumnName = $column->columnName;
            }
        }
    }
31841
public function filter(Table $table)
    {
        $this->sqlWhere = [];
        $this->sqlParams = [];

        $columns = $table->getColumns();
        foreach ($table->getFilters() as $column => $filters) {
            foreach ($filters as $name => $value) {
                $this->buildFilter($columns[$column]['sql_id'], $columns[$column]['type'], $name, $value);
            }
        }

        if (count($this->sqlWhere) == 0)
            return;

        $ands = [];
        foreach ($this->sqlWhere as $filter => $ors)
            $ands[] = '(' . join(') OR (', $ors) . ')';

        $qb = $this->getQueryBuilder();
        $qb->andWhere('(' . join(') AND (', $ands) .')');
        foreach ($this->sqlParams as $name => $value)
            $qb->setParameter($name, $value);
    }
654412
protected function addColumns(Table $table)
    {
        $stmt = $this->dbh->query("PRAGMA table_info('" . $table->getName() . "')");

        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {

            $name = $row['name'];

            $fulltype = $row['type'];
            $size = null;
            $precision = null;
            $scale = null;

            if (preg_match('/^([^\(]+)\(\s*(\d+)\s*,\s*(\d+)\s*\)$/', $fulltype, $matches)) {
                $type = $matches[1];
                $precision = $matches[2];
                $scale = $matches[3]; // aka precision
            } elseif (preg_match('/^([^\(]+)\(\s*(\d+)\s*\)$/', $fulltype, $matches)) {
                $type = $matches[1];
                $size = $matches[2];
            } else {
                $type = $fulltype;
            }
            // If column is primary key and of type INTEGER, it is auto increment
            // See: http://sqlite.org/faq.html#q1
            $autoincrement = ($row['pk'] == 1 && strtolower($type) == 'integer');
            $not_null = $row['notnull'];
            $default = $row['dflt_value'];

            $propelType = $this->getMappedPropelType(strtolower($type));
            if (!$propelType) {
                $propelType = Column::DEFAULT_TYPE;
                $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support.");
            }

            $column = new Column($name);
            $column->setTable($table);
            $column->setDomainForType($propelType);
            // We may want to provide an option to include this:
            // $column->getDomain()->replaceSqlType($type);
            $column->getDomain()->replaceSize($size);
            $column->getDomain()->replaceScale($scale);
            if ($default !== null) {
                $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
            }
            $column->setAutoIncrement($autoincrement);
            $column->setNotNull($not_null);

            if (($row['pk'] == 1) || (strtolower($type) == 'integer')) {
                $column->setPrimaryKey(true);
            }

            $table->addColumn($column);
        }
    }
1156965
protected function checkTable(string $table)
    {
        if (!in_array($table, [RoomContract::ROOMS_KEY, RoomContract::DESCRIPTORS_KEY])) {
            throw new InvalidArgumentException("Invalid table name: `{$table}`.");
        }
    }
747845
public void addColumn(DefaultTableColumn column) {
        column.setModelIndex(columnModel.getColumnCount());
        columnModel.addColumn(column);
    }
409599
protected function createTable(Table $table): void
	{
		$table->addPrimaryKey('id')
			->int()
			->setAutoIncrement();
		$table->addForeignKey('groupId', PagesLinksGroupsMapper::class);
		$table->addColumn('name')
			->text();
		$table->addColumn('url')
			->varChar();
		$table->addColumn('content')
			->text()
			->setDefault(null);
		$table->addColumn('description')
			->text()
			->setDefault(null);
		$table->addColumn('image')
			->varChar()
			->setDefault(null);
		$table->addColumn('position')
			->int(3);
		$table->addColumn('visible')
			->bool()
			->setDefault(1);
		$table->addColumn('openNewWindow')
			->bool()
			->setDefault(0);
	}
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;
    }
1364482
protected function configure_user_columns($table) {
        $table->column_suppress('picture');
        $table->column_suppress('fullname');
        $extrafields = get_extra_user_fields($this->context);
        foreach ($extrafields as $field) {
            $table->column_suppress($field);
        }

        $table->column_class('picture', 'picture');
        $table->column_class('lastname', 'bold');
        $table->column_class('firstname', 'bold');
        $table->column_class('fullname', 'bold');
    }
364413
public function filter($table)
    {
        if (empty($this->segment) || empty($this->mapping)) {
            return;
        }

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

            if (!empty($this->mapping[$label])) {
                $label = $this->mapping[$label];
                $row->setMetadata('segment', $this->segment . '==' . urlencode($label));
            }
        }
    }
272684
protected function createTable(Table $table): void
	{
		$table->addPrimaryKey('id')
			->int()
			->setAutoIncrement();
		$table->addForeignKey('pageId', PagesMapper::class);
		$table->addColumn('name')
			->text();
		$table->addColumn('quantity')
			->tinyint(2)
			->setDefault(null);
		$table->addColumn('position')
			->int(3);
		$table->addColumn('visible')
			->bool()
			->setDefault(1);
	}
923344
public function hasColumns($table, array $columns)
    {
        $tableColumns = array_map('strtolower', array_keys($this->getColumnListing($table)));

        foreach ($columns as $column) {
            if (!in_array(strtolower($column), $tableColumns)) {
                return false;
            }
        }

        return true;
    }
1347043
public function filter($table)
    {
        // always do recursive filter
        $this->enableRecursive(true);
        $recurse = false; // only recurse if there are columns to remove/keep

        // remove columns specified in $this->columnsToRemove
        if (!empty($this->columnsToRemove)) {
            $this->removeColumnsFromTable($table);
            $recurse = true;
        }

        // remove columns not specified in $columnsToKeep
        if (!empty($this->columnsToKeep)) {
            foreach ($table as $index => $row) {
                $columnsToDelete = array();
                foreach ($row as $name => $value) {
                    $keep = false;

                    // @see self::APPEND_TO_COLUMN_NAME_TO_KEEP
                    foreach ($this->columnsToKeep as $nameKeep => $true) {
                        if (strpos($name, $nameKeep . self::APPEND_TO_COLUMN_NAME_TO_KEEP) === 0) {
                            $keep = true;
                        }
                    }

                    if (!$keep
                        && $name != 'label' // label cannot be removed via whitelisting
                        && !isset($this->columnsToKeep[$name])
                    ) {
                        // we cannot remove row directly to prevent notice "ArrayIterator::next(): Array was modified
                        // outside object and internal position is no longer valid in /var/www..."
                        $columnsToDelete[] = $name;
                    }
                }
                foreach ($columnsToDelete as $columnToDelete) {
                    unset($table[$index][$columnToDelete]);
                }
            }

            $recurse = true;
        }

        // recurse
        if ($recurse && !is_array($table)) {
            foreach ($table as $row) {
                $this->filterSubTable($row);
            }
        }

        return $table;
    }
1052001
public void applyColumnFilter(String column, ChangeValue changeValue) throws Exception {
		for (String row : rowLookup.keySet()) {
			String oldValue = this.getCell(row, column);
			String newValue = changeValue.change(oldValue);
			this.addCell(row, column, newValue);
		}
	}
898305
public static function wiki_parser_table_callback($table) {
        $html = "";
        $headers = $table[0];
        $columncount = count($headers);
        $headerhtml = "";
        foreach($headers as $h) {
            $text = trim($h[1]);
            if($h[0] == 'header') {
                $headerhtml .= "\n".parser_utils::h('th', $text)."\n";
                $hasheaders = true;
            }
            else if($h[0] == 'normal'){
                $headerhtml .= "\n".parser_utils::h("td", $text)."\n";
            }
        }
        $headerhtml = "\n".parser_utils::h('tr', $headerhtml)."\n";
        $bodyhtml = "";
        if(isset($hasheaders)) {
            $html = "\n".parser_utils::h('thead', $headerhtml)."\n";
        }
        else {
            $bodyhtml .= $headerhtml;
        }

        array_shift($table);
        foreach($table as $row) {
            $htmlrow = "";
            for($i = 0; $i < $columncount; $i++) {
                $text = "";
                if(!isset($row[$i])) {
                    $htmlrow .= "\n".parser_utils::h('td', $text)."\n";
                }
                else {
                    $text = trim($row[$i][1]);
                    if($row[$i][0] == 'header') {
                        $htmlrow .= "\n".parser_utils::h('th', $text)."\n";
                    }
                    else if($row[$i][0] == 'normal'){
                        $htmlrow .= "\n".parser_utils::h('td', $text)."\n";
                    }   
                }
            }
            $bodyhtml .= "\n".parser_utils::h('tr', $htmlrow)."\n";
        }

        $html .= "\n".parser_utils::h('tbody', $bodyhtml)."\n";
        return "\n".parser_utils::h('table', $html)."\n";
    }