Generate phinx column options (default value).

@param array $attributes
@param array $columnData

@return array Attributes
328943
protected function getPhinxColumnOptionsNumeric($attributes, $columnData)
    {
        // For decimal columns
        if (!empty($columnData['NUMERIC_PRECISION'])) {
            $attributes[] = '\'precision\' => ' . $columnData['NUMERIC_PRECISION'];
        }
        if (!empty($columnData['NUMERIC_SCALE'])) {
            $attributes[] = '\'scale\' => ' . $columnData['NUMERIC_SCALE'];
        }

        // signed enable or disable the unsigned option (only applies to MySQL)
        $match = null;
        $pattern = '/\(\d+\) unsigned$/';
        if (preg_match($pattern, $columnData['COLUMN_TYPE'], $match) === 1) {
            $attributes[] = '\'signed\' => false';
        }

        // For integer and biginteger columns:
        // identity enable or disable automatic incrementing
        if ($columnData['EXTRA'] == 'auto_increment') {
            $attributes[] = '\'identity\' => \'enable\'';
        }

        return $attributes;
    }
566132
private function parseAttributes($columnName, array $attrs, $isCreate = true) {
        $return = $this->checkType($columnName, $attrs); // type

        if (strtolower($attrs['type']) === 'timestamp' && !isset($attrs['attrs']['default'])) {
            $attrs['attrs']['default'] = '"0000-00-00 00:00:00"';
        }

        if (isset($attrs['attrs']['size']))
            $return .= '(' . $attrs['attrs']['size'] . ')'; // size

        if (isset($attrs['attrs']['collation'])) {
            if (!isset($attrs['attrs']['charset']))
                $attrs['attrs']['charset'] = stristr($attrs['attrs']['collation'], '_', true);

            $return .= ' CHARACTER SET ' . $attrs['attrs']['charset'] . ' COLLATE ' . $attrs['attrs']['collation'];
        }

        $return .= (isset($attrs['attrs']['nullable']) && strtolower($attrs['attrs']['nullable']) == 'true') ? ' NULL' : ' NOT NULL'; // null

        if (isset($attrs['attrs']['default'])) { // auto increment
            if (strtolower($attrs['type']) === 'boolean') {
                if ($attrs['attrs']['default'] === 'true') {
                    $attrs['attrs']['default'] = 1;
                }
                else {
                    $attrs['attrs']['default'] = 0;
                }
            }

            $return .= (trim(strtolower($attrs['type'])) == 'timestamp') ? ' DEFAULT ' . $attrs['attrs']['default'] : ' DEFAULT "' . $attrs['attrs']['default'] . '"';
        }

        if (isset($attrs['attrs']['autoIncrement']) && $attrs['attrs']['autoIncrement'] == 'true') // auto increment
            $return .= ' AUTO_INCREMENT';
        if (!$isCreate) {
            if (!empty($attrs['attrs']['after']))
                $return .= ' AFTER `' . $attrs['attrs']['after'] . '`';
            else if (isset($attrs['attrs']['first']) && $attrs['attrs']['first'])
                $return .= ' FIRST';
        }
        if (isset($attrs['attrs']['onUpdate']) && $attrs['type'] !== 'ReferenceMany') // auto increment
            $return .= ' ON UPDATE ' . $attrs['attrs']['onUpdate'];

        return $return;
    }
678270
protected function getPhinxColumnOptionsNumeric(array $attributes, array $columnData): array
    {
        $dataType = $columnData['DATA_TYPE'];

        $intDefaultLimits = [
            'int' => '11',
            'bigint' => '20',
        ];

        // For integer and biginteger columns
        if ($dataType === 'int' || $dataType === 'bigint') {
            $match = null;
            if (preg_match('/\((\d+)\)/', $columnData['COLUMN_TYPE'], $match) === 1) {
                if ($match[1] !== $intDefaultLimits[$dataType]) {
                    $attributes['limit'] = $match[1];
                }
            }

            // signed enable or disable the unsigned option (only applies to MySQL)
            $match = null;
            $pattern = '/\(\d+\) unsigned$/';
            if (preg_match($pattern, $columnData['COLUMN_TYPE'], $match) === 1) {
                $attributes['signed'] = false;
            }

            // identity enable or disable automatic incrementing
            if ($columnData['EXTRA'] == 'auto_increment') {
                $attributes['identity'] = 'enable';
            }
        }

        // For decimal columns
        if ($dataType === 'decimal') {
            // Set decimal accuracy
            if (!empty($columnData['NUMERIC_PRECISION'])) {
                $attributes['precision'] = $columnData['NUMERIC_PRECISION'];
            }
            if (!empty($columnData['NUMERIC_SCALE'])) {
                $attributes['scale'] = $columnData['NUMERIC_SCALE'];
            }
        }

        return $attributes;
    }
1305918
public function generateGridViewField($attribute, $fk, $tableSchema = null)
    {
        if (is_null($tableSchema)) {
            $tableSchema = $this->getTableSchema();
        }

        if (in_array($attribute, $this->hiddenColumns)) {
            return "['attribute' => '$attribute', 'visible' => false],\n";
        }
        if ($tableSchema === false || !isset($tableSchema->columns[$attribute])) {
            if (preg_match('/^(password|pass|passwd|passcode)$/i', $attribute)) {
                return "";
            } else {
                return "'$attribute',\n";
            }
        }
        $column = $tableSchema->columns[$attribute];
        $format = $this->generateColumnFormat($column);
        $baseClass = StringHelper::basename($this->modelClass);

        if (array_key_exists($attribute, $fk)) {
            $rel = $fk[$attribute];
            if ($rel[self::REL_CLASS] == $baseClass) {
                return "";
            }
            $labelCol = $this->getNameAttributeFK($rel[3]);
//            $modelRel = $rel[2] ? lcfirst(Inflector::pluralize($rel[1])) : lcfirst($rel[1]);
            $output = "[
                'attribute' => '$rel[7].$labelCol',
                'label' => " . $this->generateString(ucwords(Inflector::humanize($rel[5]))) . "
            ],\n";
            return $output;
        } else {
            return "'$attribute" . ($format === 'text' ? "" : ":" . $format) . "',\n";
        }
    }
806993
protected function getColumnOption($column_key, $option_name, $default = NULL)
    {
        return isset($this->columns[$column_key][$option_name]) ? $this->columns[$column_key][$option_name] : value($default);
    }
1062267
public function virtuals($attribute = null)
    {
        $fields = [];
        foreach ($this->_columns as $name => $field) {
            if (empty($field['virtual'])) {
                continue;
            }
            $fields[] = $name;
        }
        return $fields;
    }
1146620
private function AddSetters($columnsMetadata) {
        $output = "";
        foreach ($columnsMetadata as $columnName => $columnMetadata) {
            $output .= $this->AddPropertyPhpDoc($columnMetadata);
            $placeholders = array(
                CodeSnippetPlaceholders::PROPERTY_NAME_FIRST_CAP => ucfirst($columnMetadata["Field"]),
                CodeSnippetPlaceholders::PROPERTY_NAME => $columnMetadata["Field"]);
            $output .=
                    $this->_TAB2 .
                    strtr(CodeSnippets\ClassFileSnippets::SNIPPET_SET_PROPERTY_START, $placeholders) . $this->_LF;
            $output .=
                    $this->_TAB6 .
                    strtr(CodeSnippets\ClassFileSnippets::SNIPPET_SET_PROPERTY_ASSIGNMENT, $placeholders) .
                    $this->_LF;
            $output .= $this->_TAB2 . CodeSnippets\ClassFileSnippets::SNIPPET_CLOSING_CURLY_BRACKET . $this->_CRLF;
        }
        fwrite($this->writer, $output);
    }
803982
protected function _safeDropColumn($table, $columnData)
	{
		$columnName = $columnData['name'];
		$dropColumnStatement = '';

		if ($this->db->tableHasField($table, $columnName))
		{
			$dropColumnStatement = with(new QueryDropColumnStatement($columnData))
				->toString();
		}

		return $dropColumnStatement;
	}
612110
public function findWhereNotIn($attribute, $values, $columns = ['*'], $with = [])
    {
        $values   = $this->castRequest($values);
        $cacheKey = $this->generateKey([$attribute, $values, $columns, $with]);

        return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($attribute, $values, $columns, $with) {
            return $this->model->with($with)
                ->whereNotIn($attribute, $values)
                ->get($columns);
        });
    }
299645
public static function columnSum($dataProvider, $attributes)
    {
        $result = 0;
        foreach ($dataProvider->models as $model) {
            foreach ((array) $attributes as $attribute) {
                $result += $model[$attribute];
            }
        }
        return $result;
    }
853180
protected function seedRowData(string $tableName, array $data, array $columnTypes = []): void
    {
        $attributeTypeGetter = $this->createAttributeTypeGetter($columnTypes);

        $this->insertRow($tableName, $this->getConnection(), $data, $attributeTypeGetter);
    }
1301149
protected function processAttributeOptions(array $data, Attribute $attribute)
    {
        if (isset($data['type'])) {
            $this->processDataType($data['type'], $attribute);
        }

        if (isset($data['many'])) {
            $attribute->setMany($data['many']);
        }

        if (isset($data['processNull'])) {
            $attribute->setProcessNull($data['processNull']);
        }
    }
528578
protected function columnIndex( $columnIdent )
    {
        $matrix = $this->attribute( 'matrix' );
        $columns = $matrix['columns']['sequential'];

        foreach( $columns as $key => $column )
        {
            if ( $column['identifier'] == $columnIdent )
            {
                return $key;
            }
        }

        return false;
    }
625088
protected function getSelectColumns() {
		//obtain attributes from config
		if ($this->hasOption('query.attrs')) {
			$columns = [];
			
			foreach ($this->getOption('query.attrs') as $attr) {
				if ($attr instanceof Attr)
					$name = $attr->getName();				
				elseif (is_string($attr))
					$name = $attr;
				else
					throw new \InvalidArgumentException("Method 'attrs' expects a list of strings or instances of \eMapper\Query\Attr");
				
				if (!$this->entityProfile->hasProperty($name))
					throw new \InvalidArgumentException(sprintf("Attribute '%s' not found in class '%s'", $name, $this->entityProfile->getReflectionClass()->getName()));
				
				$column = $this->entityProfile->getProperty($name)->getColumn();
				if (!array_key_exists($column, $columns))
					$columns[$column] = new Column($column);
			}
			
			return $columns;
		}
	
		return $this->selectColumns;
	}
713851
public function makeAttributesForOption ($attributes)
    {
        $attrs = '';
        if ($attributes) {
            foreach ($attributes as $key => $value) {
                $attrs .= "$key='" . $value . "'";
            }
        }
        return $attrs;
    }
203417
protected function getColumnCreate($schema, $table, $columnName)
    {
        $columns = $schema['tables'][$table]['columns'];
        $columnData = $columns[$columnName];
        $phinxType = $this->getPhinxColumnType($columnData);
        $columnAttributes = $this->getPhinxColumnOptions($phinxType, $columnData, $columns);

        return [$table, $columnName, $phinxType, $columnAttributes];
    }
291545
public static function addColumns($tableName, array $columnDefinitions)
    {
        return [
            'up' => function (Builder $schema) use ($tableName, $columnDefinitions) {
                $schema->table($tableName, function (Blueprint $table) use ($schema, $columnDefinitions) {
                    foreach ($columnDefinitions as $columnName => $options) {
                        $type = array_shift($options);
                        $table->addColumn($type, $columnName, $options);
                    }
                });
            },
            'down' => function (Builder $schema) use ($tableName, $columnDefinitions) {
                $schema->table($tableName, function (Blueprint $table) use ($columnDefinitions) {
                    $table->dropColumn(array_keys($columnDefinitions));
                });
            }
        ];
    }