Ruckusing_Adapter_PgSQL_Base::add_column_options PHP Method

add_column_options() public method

Add column options
public add_column_options ( string $type, array $options, boolean $performing_change = false ) : string
$type string the native type
$options array
$performing_change boolean
return string
    public function add_column_options($type, $options, $performing_change = false)
    {
        $sql = "";
        if (!is_array($options)) {
            return $sql;
        }
        if (!$performing_change) {
            if (array_key_exists('default', $options) && $options['default'] !== null) {
                if (is_int($options['default'])) {
                    $default_format = '%d';
                } elseif (is_bool($options['default'])) {
                    $default_format = "'%d'";
                } else {
                    $default_format = "'%s'";
                }
                $default_value = sprintf($default_format, $options['default']);
                $sql .= sprintf(" DEFAULT %s", $default_value);
            }
            if (array_key_exists('null', $options) && $options['null'] === false) {
                $sql .= " NOT NULL";
            }
        }
        return $sql;
    }