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

_buildColumn() protected method

Helper for Database::column().
See also: lithium\data\source\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';
        }
        if ($precision) {
            $precision = $use === 'numeric' ? ",{$precision}" : '';
        }
        $out = $this->name($name);
        if (isset($increment) && $increment) {
            $out .= ' serial NOT NULL';
        } else {
            $out .= ' ' . $use;
            if ($length && preg_match('/char|numeric|interval|bit|time/', $use)) {
                $out .= "({$length}{$precision})";
            }
            $out .= is_bool($null) ? $null ? ' NULL' : ' NOT NULL' : '';
            $out .= $default ? ' DEFAULT ' . $this->value($default, $field) : '';
        }
        return $out;
    }