src/Services/PDOs/Schemas/Schema.php
protected function compileColumnDefinition(array $options)
    {
        $options = array_merge([
            'type'      => null,
            'size'      => null,
            'scale'     => null,
            'nullable'  => false,
            'default'   => null,
            'collation' => null,
            'comment'   => null,
        ], $options);

        $type   = strtolower($options['type']);

        if ($type == 'identity') { // Is the column the auto-incremented primary key?
            $sql = 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT';
        }
        else if ($type == 'bigidentity') {
            $sql = 'BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT';
        }
        else {
            $size   = $options['size'];
            $scale  = $options['scale'];
            $sql = $this->compileFieldType($type, $size, $scale);

            if (!$options['nullable']) {
                $sql .= ' NOT NULL';
            }

            if ($options['default'] !== null) {
                $default = $options['default'];
                if (is_string($default) && $default != 'CURRENT_TIMESTAMP') {
                    $default = $this->db->quote($options['default']);
                } else if (is_bool($default)) {
                    $default = $default ? '1' : '0';
                }
                $sql .= ' DEFAULT ' . $default;
            }

            if (!empty($options['collation'])) {
                $sql .= ' COLLATE ' . $options['collation'];
            }
        }

        $comment = $options['comment'];
        if ($this->needATypeHint($type)) {
            $comment = ($comment !== null ? $comment . ' ' : '') . '(DC2Type:' . $type . ')';
        }

        if (!is_null($comment)) {
            $sql .= ' COMMENT ' . $this->db->quote($comment);
        }

        return $sql;
    }
protected function compileColumnDefinition(array $options)
    {
        $options = array_merge([
            'type'      => null,
            'size'      => null,
            'scale'     => null,
            'nullable'  => false,
            'default'   => null,
            'collation' => null,
            'comment'   => null,
        ], $options);

        $type   = strtolower($options['type']);

        if ($type == 'identity') { // Is the column the auto-incremented primary key?
            $sql = 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT';
        }
        else if ($type == 'bigidentity') {
            $sql = 'BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT';
        }
        else {
            $size   = $options['size'];
            $scale  = $options['scale'];
            $sql = $this->compileFieldType($type, $size, $scale);

            if (!$options['nullable']) {
                $sql .= ' NOT NULL';
            }

            if ($options['default'] !== null) {
                $default = $options['default'];
                if (is_string($default) && $default != 'CURRENT_TIMESTAMP') {
                    $default = $this->db->quote($options['default']);
                } else if (is_bool($default)) {
                    $default = $default ? '1' : '0';
                }
                $sql .= ' DEFAULT ' . $default;
            }

            if (!empty($options['collation'])) {
                $sql .= ' COLLATE ' . $options['collation'];
            }
        }

        $comment = $options['comment'];
        if ($this->needATypeHint($type)) {
            $comment = ($comment !== null ? $comment . ' ' : '') . '(DC2Type:' . $type . ')';
        }

        if (!is_null($comment)) {
            $sql .= ' COMMENT ' . $this->db->quote($comment);
        }

        return $sql;
    }
protected function compileColumnDefinition ( array $ options ) { $ options = array_merge ( [ 'type' => null , 'size' => null , 'scale' => null , 'nullable' => false , 'default' => null , 'collation' => null , 'comment' => null , ] , $ options ) ; $ type = strtolower ( $ options [ 'type' ] ) ; if ( $ type == 'identity' ) { // Is the column the auto-incremented primary key? $ sql = 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT' ; } else if ( $ type == 'bigidentity' ) { $ sql = 'BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT' ; } else { $ size = $ options [ 'size' ] ; $ scale = $ options [ 'scale' ] ; $ sql = $ this -> compileFieldType ( $ type , $ size , $ scale ) ; if ( ! $ options [ 'nullable' ] ) { $ sql .= ' NOT NULL' ; } if ( $ options [ 'default' ] !== null ) { $ default = $ options [ 'default' ] ; if ( is_string ( $ default ) && $ default != 'CURRENT_TIMESTAMP' ) { $ default = $ this -> db -> quote ( $ options [ 'default' ] ) ; } else if ( is_bool ( $ default ) ) { $ default = $ default ? '1' : '0' ; } $ sql .= ' DEFAULT ' . $ default ; } if ( ! empty ( $ options [ 'collation' ] ) ) { $ sql .= ' COLLATE ' . $ options [ 'collation' ] ; } } $ comment = $ options [ 'comment' ] ; if ( $ this -> needATypeHint ( $ type ) ) { $ comment = ( $ comment !== null ? $ comment . ' ' : '' ) . '(DC2Type:' . $ type . ')' ; } if ( ! is_null ( $ comment ) ) { $ sql .= ' COMMENT ' . $ this -> db -> quote ( $ comment ) ; } return $ sql ; }
Compile the column definitions.

This function is used by createTable() and addColumn().

Options have following properties:
- type:      (string) The column data type. Data types are as reported by the database.
- size:      (int)    The column size (the maximum number of digits).
- scale:     (int)    The number of digits to the right of the numeric point. It must be no larger than size.
- nullable:  (bool)   The column is not marked as NOT NULL.
- default:   (mixed)  The default value for the column.
- collation: (string) The collation of the column.
- comment:   (string) A hidden comment.

@param array $options
@return string
Compile the column definitions .