Adds a column (in form: ['header' => [values]] or ['header' => 'value']) to a given table.

@param TableNode $table
@param array $columnData

@return TableNode

@throws \Behat\Gherkin\Exception\NodeException
965328
public static function addColumn(TableNode $table, array $columnData): TableNode
    {
        $headers = array_keys($columnData);

        $newParameters = $table->getTable();

        foreach ($headers as $header) {
            $row = array_keys($table->getTable())[0];
            $newParameters[$row++][] = $header;
            if (\is_array($columnData[$header])) {
                foreach ($columnData[$header] as $value) {
                    $newParameters[$row++][] = $value;
                }
            } else {
                $newParameters[$row][] = $columnData[$header];
            }
        }

        return new self($newParameters);
    }
1121135
public function dropColumn($table, $columnName)
    {
        $table = $this->prefixTable($table);

        return $this->container->make('Piwik\Updater\Migration\Db\DropColumn', array(
            'table' => $table, 'columnName' => $columnName
        ));
    }
493905
public function addTable(Table $table)
    {
        $this->tables->set($table->getTableName(), $table);
        
        return $this;
    }
804324
private function addHTMLTable($headers, $data, $options = [])
    {
        $w = (isset($options['width']) and is_array($options['width'])) ? $options['width'] : null;
        $a = (isset($options['align']) and is_array($options['align'])) ? $options['align'] : [];
        $buffer = '<table style="border:1px solid #333">';
        // Definir títulos de columnas
        $thead = isset($options['width']) and is_array($options['width']) and count($options['width']) == count($headers);
        if ($thead)
            $buffer .= '<thead>';
        $buffer .= '<tr>';
        $i = 0;
        foreach ($headers as &$col) {
            $width = ($w and isset($w[$i])) ? (';width:'.$w[$i].'mm') : '';
            $align = isset($a[$i]) ? $a[$i] : 'center';
            $buffer .= '<th style="border-right:1px solid #333;border-bottom:1px solid #333;text-align:'.$align.$width.'"><strong>'.strip_tags($col).'</strong></th>';
            $i++;
        }
        $buffer .= '</tr>';
        if ($thead)
            $buffer .= '</thead>';
        // Definir datos de la tabla
        if ($thead)
            $buffer .= '<tbody>';
        foreach ($data as &$row) {
            $buffer .= '<tr>';
            $i = 0;
            foreach ($row as &$col) {
                $width = ($w and isset($w[$i])) ? (';width:'.$w[$i].'mm') : '';
                $align = isset($a[$i]) ? $a[$i] : 'center';
                $buffer .= '<td style="border-right:1px solid #333;text-align:'.$align.$width.'">'.$col.'</td>';
                $i++;
            }
            $buffer .= '</tr>';
        }
        if ($thead)
            $buffer .= '</tbody>';
        // Finalizar tabla
        $buffer .= '</table>';
        // generar tabla en HTML
        $this->writeHTML($buffer, true, false, false, false, '');
    }
276807
public function iFillFormWith(TableNode $table)
    {
        foreach (GherkinHelper::convertTableToArrayOfData($table) as $field => $value) {
            // fill the form
            $el = $this->findFieldElement($field);
            $el->setValue($value);
        }
    }
1181392
public static function tableColumn(Table $table, string $columnName) : ColumnExpr
    {
        if (!$table->hasColumn($columnName)) {
            throw InvalidArgumentException::format(
                'Invalid table column name for table \'%s\': expecting one of (%s), \'%s\' given',
                $table->getName(), Debug::formatValues($table->getColumnNames()), $columnName
            );
        }

        return new ColumnExpr($table->getName(), $table->findColumn($columnName));
    }
1329503
protected function getColumnCreateAddNoUpdate(array $schema, string $table, string $columnName): string
    {
        $result = $this->getColumnCreate($schema, $table, $columnName);

        return sprintf("%s->addColumn('%s', '%s', %s)", $this->ind3, $result[1], $result[2], $result[3]);
    }
1349559
private function createColumns(Table $table)
    {
        $table->addColumn(RdsDeliveryExecutionService::COLUMN_ID, Type::STRING, ["length" => 255, "notnull" => true]);
        $table->addColumn(RdsDeliveryExecutionService::COLUMN_DELIVERY_ID, Type::STRING, ["length" => 255, "notnull" => true]);
        $table->addColumn(RdsDeliveryExecutionService::COLUMN_USER_ID, Type::STRING, ["length" => 255, "notnull" => true]);
        $table->addColumn(RdsDeliveryExecutionService::COLUMN_LABEL, Type::STRING, ["length" => 255, "notnull" => true]);
        $table->addColumn(RdsDeliveryExecutionService::COLUMN_STATUS, Type::STRING, ["length" => 255, "notnull" => true]);
        $table->addColumn(RdsDeliveryExecutionService::COLUMN_STARTED_AT, Type::DATETIME, ["notnull" => true]);
        $table->addColumn(RdsDeliveryExecutionService::COLUMN_FINISHED_AT, Type::DATETIME, ["notnull" => false]);
        $table->setPrimaryKey([RdsDeliveryExecutionService::COLUMN_ID]);
    }
41069
public function addColumnName($columnName)
    {
        if (!is_string($columnName) || (strlen($columnName) <= 0)) {
            throw SchemaException::invalidIndexColumnName($this->getName());
        }

        $this->columnNames[] = $columnName;
    }
9723
public static function insert($table, $data) {
        $insert = Insert::table($table);
        foreach ($data as $field => $value) {
            $insert->set($field, $value);
        }
        return $insert->excuse();
    }
1088933
public function addIrreToData(&$data, $table = "tt_content", $cType = "")
    {

        if ($cType == "") {
            $cType = $data["CType"];
        }

        $fieldHelper = GeneralUtility::makeInstance(FieldHelper::class);
        $storage = $this->storageRepository->load();
        $elementFields = [];

        // if the table is tt_content, load the element and all its columns
        if ($table == "tt_content") {
            $element = $this->storageRepository->loadElement($table, str_replace("mask_", "", $cType));
            $elementFields = $element["columns"];
        } elseif ($table == "pages") {
            // if the table is pages, then load the pid
            if (isset($data['uid'])) {

                // find the backendlayout by the pid
                $backendLayoutIdentifier = $this->backendLayoutRepository->findIdentifierByPid($data['uid']);

                // if a backendlayout was found, then load its elements
                if ($backendLayoutIdentifier) {
                    $element = $this->storageRepository->loadElement(
                        $table,
                        str_replace('pagets__', '', $backendLayoutIdentifier)
                    );
                    $elementFields = $element["columns"];
                } else {

                    // if no backendlayout was found, just load all fields, if there are fields
                    if (isset($storage[$table]['tca'])) {
                        $elementFields = array_keys($storage[$table]['tca']);
                    }

                }
            }
        } elseif (isset($storage[$table])) {
            // otherwise check if its a table at all, if yes load all fields
            $elementFields = array_keys($storage[$table]['tca']);
        }

        // if the element has columns
        if ($elementFields) {

            // check foreach column
            foreach ($elementFields as $field) {

                $fieldKeyPrefix = $field;
                $fieldKey = str_replace("tx_mask_", "", $field);
                $type = $fieldHelper->getFormType($fieldKey, $cType, $table);

                // if it is of type inline and has to be filled (IRRE, FAL)
                if ($type == "Inline") {
                    $elements = $this->getInlineElements($data, $fieldKeyPrefix, $cType, "parentid", $table);
                    $data[$fieldKeyPrefix] = $elements;
                    // or if it is of type Content (Nested Content) and has to be filled
                } elseif ($type == "Content") {
                    $elements = $this->getInlineElements($data, $fieldKeyPrefix, $cType, $fieldKeyPrefix . "_parent",
                        "tt_content", "tt_content");
                    $data[$fieldKeyPrefix] = $elements;
                }
            }
        }
    }
703577
public function execute(NodeData $node)
    {
        $newNodePath = $node->getParentPath() . '/' . $this->newName;
        $node->setPath($newNodePath);
    }
1059310
public function renderTableNode(TableNode $table)
    {
        $arguments = '<table class="argument"> <thead>';
        $header = $table->getRow(0);
        $arguments .= $this->preintTableRows($header);

        $arguments .= '</thead><tbody>';
        foreach ($table->getHash() as $row) {
            $arguments .= $this->preintTableRows($row);
        }

        $arguments .= '</tbody></table>';

        return $arguments;
    }
949753
protected function insertHead( $table, $columns ) {

        $quotedColumns = array_map( array( $this, 'quoteIdentifier' ), $columns );
        $table = $this->rewriteTable( $table );
        $query = "INSERT INTO " . $this->quoteIdentifier( $table );
        $query .= " ( " . implode( ", ", $quotedColumns ) . " ) VALUES ";

        return $query;

    }
1190803
protected function addColumns(Table $table)
    {
        $tableName = $table->getName();

//        var_dump("PRAGMA table_info('$tableName') //");
        $stmt = $this->dbh->query("PRAGMA table_info('$tableName')");

        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $name = $row['name'];

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

            if (preg_match('/^([^\(]+)\(\s*(\d+)\s*,\s*(\d+)\s*\)$/', $fulltype, $matches)) {
                $type = $matches[1];
                $size = $matches[2];
                $scale = $matches[3];
            } elseif (preg_match('/^([^\(]+)\(\s*(\d+)\s*\)$/', $fulltype, $matches)) {
                $type = $matches[1];
                $size = $matches[2];
            } else {
                $type = $fulltype;
            }
            $notNull = $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 (null !== $default) {
                if ("'" !== substr($default, 0, 1) && strpos($default, '(')) {
                    $defaultType = ColumnDefaultValue::TYPE_EXPR;
                    if ('datetime(CURRENT_TIMESTAMP, \'localtime\')' === $default) {
                            $default = 'CURRENT_TIMESTAMP';
                        }
                } else {
                    $defaultType = ColumnDefaultValue::TYPE_VALUE;
                    $default = str_replace("'", '', $default);
                }
                $column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, $defaultType));
            }

            $column->setNotNull($notNull);

            if (0 < $row['pk']+0) {
                $column->setPrimaryKey(true);
            }

            if ($column->isPrimaryKey()) {
                // check if autoIncrement
                $autoIncrementStmt = $this->dbh->prepare('
                SELECT tbl_name
                FROM sqlite_master
                WHERE
                  tbl_name = ?
                AND
                  sql LIKE "%AUTOINCREMENT%"
                ');
                $autoIncrementStmt->execute([$table->getName()]);
                $autoincrementRow = $autoIncrementStmt->fetch(\PDO::FETCH_ASSOC);
                if ($autoincrementRow && $autoincrementRow['tbl_name'] == $table->getName()) {
                    $column->setAutoIncrement(true);
                }
            }

            $table->addColumn($column);
        }
    }
723932
public function addColumn(string $column, array $definition = []) : Table
    {
        $this->data['columns'][$column] = TableColumn::fromArray($column, $definition);
        return $this;
    }
515510
public function execute(NodeData $node)
    {
        $dimensionValuesToBeAdded = $node->getDimensionValues();

        foreach ($this->dimensionValues as $dimensionName => $dimensionValues) {
            if (!isset($dimensionValuesToBeAdded[$dimensionName])) {
                if (is_array($dimensionValues)) {
                    $dimensionValuesToBeAdded[$dimensionName] = $dimensionValues;
                } else {
                    $dimensionValuesToBeAdded[$dimensionName] = [$dimensionValues];
                }
            }
        }

        if ($this->addDefaultDimensionValues === true) {
            $configuredDimensions = $this->contentDimensionRepository->findAll();
            foreach ($configuredDimensions as $configuredDimension) {
                if (!isset($dimensionValuesToBeAdded[$configuredDimension->getIdentifier()])) {
                    $dimensionValuesToBeAdded[$configuredDimension->getIdentifier()] = [$configuredDimension->getDefault()];
                }
            }
        }

        $dimensionsToBeSet = [];
        foreach ($dimensionValuesToBeAdded as $dimensionName => $dimensionValues) {
            foreach ($dimensionValues as $dimensionValue) {
                $dimensionsToBeSet[] = new NodeDimension($node, $dimensionName, $dimensionValue);
            }
        }

        $node->setDimensions($dimensionsToBeSet);
    }