lithium\data\source\database\adapter\Sqlite3::_buildColumn PHP Method

_buildColumn() protected method

Helper for Database::column().
See also: lithium\data\Database::column()
protected _buildColumn ( array $field ) : string
$field array A field array.
return string SQL column string.
    protected function _buildColumn($field)
    {
        extract($field);
        if ($type === 'float' && $precision) {
            $use = 'numeric';
        }
        $out = $this->name($name) . ' ' . $use;
        $allowPrecision = preg_match('/^(integer|real|numeric)$/', $use);
        $precision = $precision && $allowPrecision ? ",{$precision}" : '';
        if ($length && ($allowPrecision || $use === 'text')) {
            $out .= "({$length}{$precision})";
        }
        $out .= $this->_buildMetas('column', $field, array('collate'));
        if ($type !== 'id') {
            $out .= is_bool($null) ? $null ? ' NULL' : ' NOT NULL' : '';
            $out .= $default ? ' DEFAULT ' . $this->value($default, $field) : '';
        }
        return $out;
    }