src/Titon/Db/Driver/Schema.php
public function addColumn($column, $options) {
        if (is_string($options)) {
            $options = ['type' => $options];
        }

        $options = $options + [
            'field' => $column,
            'type' => '',
            'length' => '',
            'default' => '',
            'comment' => '',
            'charset' => '',
            'collate' => '',
            'null' => true,
            'ai' => false,
            'index' => false,        // KEY index (field[, field])
            'primary' => false,      // [CONSTRAINT symbol] PRIMARY KEY (field[, field])
            'unique' => false,       // [CONSTRAINT symbol] UNIQUE KEY index (field[, field])
            'foreign' => false       // [CONSTRAINT symbol] FOREIGN KEY (field) REFERENCES table(field) [ON DELETE CASCADE, etc]
        ];

        // Force to NOT NULL for primary or auto increment columns
        if ($options['primary'] || $options['ai']) {
            $options['null'] = false;
        }

        // Filter out values so that type defaults can be inherited
        $this->_columns[$column] = array_filter($options, function($value) {
            return ($value !== '' && $value !== false);
        });

        if ($options['primary']) {
            $this->addPrimary($column, $options['primary']);

        } else if ($options['unique']) {
            $this->addUnique($column, $options['unique']);

        } else if ($options['foreign']) {
            $this->addForeign($column, $options['foreign']);
        }

        if ($options['index']) {
            $this->addIndex($column, $options['index']);
        }

        return $this;
    }
public function addColumn($column, $options) {
        if (is_string($options)) {
            $options = ['type' => $options];
        }

        $options = $options + [
            'field' => $column,
            'type' => '',
            'length' => '',
            'default' => '',
            'comment' => '',
            'charset' => '',
            'collate' => '',
            'null' => true,
            'ai' => false,
            'index' => false,        // KEY index (field[, field])
            'primary' => false,      // [CONSTRAINT symbol] PRIMARY KEY (field[, field])
            'unique' => false,       // [CONSTRAINT symbol] UNIQUE KEY index (field[, field])
            'foreign' => false       // [CONSTRAINT symbol] FOREIGN KEY (field) REFERENCES table(field) [ON DELETE CASCADE, etc]
        ];

        // Force to NOT NULL for primary or auto increment columns
        if ($options['primary'] || $options['ai']) {
            $options['null'] = false;
        }

        // Filter out values so that type defaults can be inherited
        $this->_columns[$column] = array_filter($options, function($value) {
            return ($value !== '' && $value !== false);
        });

        if ($options['primary']) {
            $this->addPrimary($column, $options['primary']);

        } else if ($options['unique']) {
            $this->addUnique($column, $options['unique']);

        } else if ($options['foreign']) {
            $this->addForeign($column, $options['foreign']);
        }

        if ($options['index']) {
            $this->addIndex($column, $options['index']);
        }

        return $this;
    }
public function addColumn ( $ column , $ options ) { if ( is_string ( $ options ) ) { $ options = [ 'type' => $ options ] ; } $ options = $ options + [ 'field' => $ column , 'type' => '' , 'length' => '' , 'default' => '' , 'comment' => '' , 'charset' => '' , 'collate' => '' , 'null' => true , 'ai' => false , 'index' => false , // KEY index (field[, field]) 'primary' => false , // [CONSTRAINT symbol] PRIMARY KEY (field[, field]) 'unique' => false , // [CONSTRAINT symbol] UNIQUE KEY index (field[, field]) 'foreign' => false // [CONSTRAINT symbol] FOREIGN KEY (field) REFERENCES table(field) [ON DELETE CASCADE, etc] ] ; // Force to NOT NULL for primary or auto increment columns if ( $ options [ 'primary' ] || $ options [ 'ai' ] ) { $ options [ 'null' ] = false ; } // Filter out values so that type defaults can be inherited $ this -> _columns [ $ column ] = array_filter ( $ options , function ( $ value ) { return ( $ value !== '' && $ value !== false ) ; } ) ; if ( $ options [ 'primary' ] ) { $ this -> addPrimary ( $ column , $ options [ 'primary' ] ) ; } else if ( $ options [ 'unique' ] ) { $ this -> addUnique ( $ column , $ options [ 'unique' ] ) ; } else if ( $ options [ 'foreign' ] ) { $ this -> addForeign ( $ column , $ options [ 'foreign' ] ) ; } if ( $ options [ 'index' ] ) { $ this -> addIndex ( $ column , $ options [ 'index' ] ) ; } return $ this ; }
Add a column to the table schema.

@param string $column
@param array $options {
@type string $type      The column data type (one of Titon\Db\Driver\Type)
@type int $length       The column data length
@type mixed $default    The default value
@type string $comment   The comment
@type string $charset   The character set for encoding
@type string $collation The collation set
@type bool $null        Does the column allow nulls
@type bool $ai          Is this an auto incrementing column
@type mixed $index      Is this an index
@type mixed $primary    Is this a primary key
@type mixed $unique     Is this a unique key
@type mixed $foreign    Is this a foreign key
}
@return $this
Add a column to the table schema .