src/Titon/Db/Driver/Dialect/AbstractDialect.php
public function formatColumns(Schema $schema) {
        $columns = [];

        foreach ($schema->getColumns() as $column => $options) {
            $dataType = $this->getDriver()->getType($options['type']);

            $options = $options + $dataType->getDefaultOptions();
            $type = $options['type'];

            if (!empty($options['length'])) {
                $type .= '(' . $options['length'] . ')';
            }

            $output = [$this->quote($column), strtoupper($type)];

            // Integers
            if (!empty($options['unsigned'])) {
                $output[] = $this->getKeyword(self::UNSIGNED);
            }

            if (!empty($options['zerofill'])) {
                $output[] = $this->getKeyword(self::ZEROFILL);
            }

            // Strings
            if (!empty($options['charset'])) {
                $output[] = sprintf($this->getClause(self::CHARACTER_SET), $options['charset']);
            }

            if (!empty($options['collate'])) {
                $output[] = sprintf($this->getClause(self::COLLATE), $options['collate']);
            }

            // Primary and uniques can't be null
            if (!empty($options['primary']) || !empty($options['unique'])) {
                $output[] = $this->getKeyword(self::NOT_NULL);
            } else {
                $output[] = $this->getKeyword(empty($options['null']) ? self::NOT_NULL : self::NULL);
            }

            if (array_key_exists('default', $options)) {
                $output[] = $this->formatDefault($options['default']);
            }

            if (!empty($options['ai'])) {
                $output[] = $this->getKeyword(self::AUTO_INCREMENT);
            }

            if (!empty($options['comment'])) {
                $output[] = sprintf($this->getClause(self::COMMENT), $this->getDriver()->escape(substr($options['comment'], 0, 255)));
            }

            $columns[] = trim(implode(' ', $output));
        }

        return implode(",\n", $columns);
    }
public function formatColumns(Schema $schema) {
        $columns = [];

        foreach ($schema->getColumns() as $column => $options) {
            $dataType = $this->getDriver()->getType($options['type']);

            $options = $options + $dataType->getDefaultOptions();
            $type = $options['type'];

            if (!empty($options['length'])) {
                $type .= '(' . $options['length'] . ')';
            }

            $output = [$this->quote($column), strtoupper($type)];

            // Integers
            if (!empty($options['unsigned'])) {
                $output[] = $this->getKeyword(self::UNSIGNED);
            }

            if (!empty($options['zerofill'])) {
                $output[] = $this->getKeyword(self::ZEROFILL);
            }

            // Strings
            if (!empty($options['charset'])) {
                $output[] = sprintf($this->getClause(self::CHARACTER_SET), $options['charset']);
            }

            if (!empty($options['collate'])) {
                $output[] = sprintf($this->getClause(self::COLLATE), $options['collate']);
            }

            // Primary and uniques can't be null
            if (!empty($options['primary']) || !empty($options['unique'])) {
                $output[] = $this->getKeyword(self::NOT_NULL);
            } else {
                $output[] = $this->getKeyword(empty($options['null']) ? self::NOT_NULL : self::NULL);
            }

            if (array_key_exists('default', $options)) {
                $output[] = $this->formatDefault($options['default']);
            }

            if (!empty($options['ai'])) {
                $output[] = $this->getKeyword(self::AUTO_INCREMENT);
            }

            if (!empty($options['comment'])) {
                $output[] = sprintf($this->getClause(self::COMMENT), $this->getDriver()->escape(substr($options['comment'], 0, 255)));
            }

            $columns[] = trim(implode(' ', $output));
        }

        return implode(",\n", $columns);
    }
public function formatColumns ( Schema $ schema ) { $ columns = [ ] ; foreach ( $ schema -> getColumns ( ) as $ column => $ options ) { $ dataType = $ this -> getDriver ( ) -> getType ( $ options [ 'type' ] ) ; $ options = $ options + $ dataType -> getDefaultOptions ( ) ; $ type = $ options [ 'type' ] ; if ( ! empty ( $ options [ 'length' ] ) ) { $ type .= '(' . $ options [ 'length' ] . ')' ; } $ output = [ $ this -> quote ( $ column ) , strtoupper ( $ type ) ] ; // Integers if ( ! empty ( $ options [ 'unsigned' ] ) ) { $ output [ ] = $ this -> getKeyword ( self :: UNSIGNED ) ; } if ( ! empty ( $ options [ 'zerofill' ] ) ) { $ output [ ] = $ this -> getKeyword ( self :: ZEROFILL ) ; } // Strings if ( ! empty ( $ options [ 'charset' ] ) ) { $ output [ ] = sprintf ( $ this -> getClause ( self :: CHARACTER_SET ) , $ options [ 'charset' ] ) ; } if ( ! empty ( $ options [ 'collate' ] ) ) { $ output [ ] = sprintf ( $ this -> getClause ( self :: COLLATE ) , $ options [ 'collate' ] ) ; } // Primary and uniques can't be null if ( ! empty ( $ options [ 'primary' ] ) || ! empty ( $ options [ 'unique' ] ) ) { $ output [ ] = $ this -> getKeyword ( self :: NOT_NULL ) ; } else { $ output [ ] = $ this -> getKeyword ( empty ( $ options [ 'null' ] ) ? self :: NOT_NULL : self :: NULL ) ; } if ( array_key_exists ( 'default' , $ options ) ) { $ output [ ] = $ this -> formatDefault ( $ options [ 'default' ] ) ; } if ( ! empty ( $ options [ 'ai' ] ) ) { $ output [ ] = $ this -> getKeyword ( self :: AUTO_INCREMENT ) ; } if ( ! empty ( $ options [ 'comment' ] ) ) { $ output [ ] = sprintf ( $ this -> getClause ( self :: COMMENT ) , $ this -> getDriver ( ) -> escape ( substr ( $ options [ 'comment' ] , 0 , 255 ) ) ) ; } $ columns [ ] = trim ( implode ( ' ' , $ output ) ) ; } return implode ( ",\n" , $ columns ) ; }
Format columns for a table schema.

@param \Titon\Db\Driver\Schema $schema
@return string
Format columns for a table schema .