lithium\data\source\database\adapter\MySql::_buildColumn PHP Méthode

_buildColumn() protected méthode

Helper for Database::column()
See also: lithium\data\Database::column()
protected _buildColumn ( array $field ) : string
$field array A field array.
Résultat string The SQL column string.
    protected function _buildColumn($field)
    {
        extract($field);
        if ($type === 'float' && $precision) {
            $use = 'decimal';
        }
        $out = $this->name($name) . ' ' . $use;
        $allowPrecision = preg_match('/^(decimal|float|double|real|numeric)$/', $use);
        $precision = $precision && $allowPrecision ? ",{$precision}" : '';
        if ($length && ($allowPrecision || preg_match('/(char|binary|int|year)/', $use))) {
            $out .= "({$length}{$precision})";
        }
        $out .= $this->_buildMetas('column', $field, array('charset', 'collate'));
        if (isset($increment) && $increment) {
            $out .= ' NOT NULL AUTO_INCREMENT';
        } else {
            $out .= is_bool($null) ? $null ? ' NULL' : ' NOT NULL' : '';
            $out .= $default ? ' DEFAULT ' . $this->value($default, $field) : '';
        }
        return $out . $this->_buildMetas('column', $field, array('comment'));
    }