framework/db/sqlite/Schema.php
protected function loadColumnSchema($info)
    {
        $column = $this->createColumnSchema();
        $column->name = $info['name'];
        $column->allowNull = !$info['notnull'];
        $column->isPrimaryKey = $info['pk'] != 0;

        $column->dbType = strtolower($info['type']);
        $column->unsigned = strpos($column->dbType, 'unsigned') !== false;

        $column->type = self::TYPE_STRING;
        if (preg_match('/^(\w+)(?:\(([^\)]+)\))?/', $column->dbType, $matches)) {
            $type = strtolower($matches[1]);
            if (isset($this->typeMap[$type])) {
                $column->type = $this->typeMap[$type];
            }

            if (!empty($matches[2])) {
                $values = explode(',', $matches[2]);
                $column->size = $column->precision = (int) $values[0];
                if (isset($values[1])) {
                    $column->scale = (int) $values[1];
                }
                if ($column->size === 1 && ($type === 'tinyint' || $type === 'bit')) {
                    $column->type = 'boolean';
                } elseif ($type === 'bit') {
                    if ($column->size > 32) {
                        $column->type = 'bigint';
                    } elseif ($column->size === 32) {
                        $column->type = 'integer';
                    }
                }
            }
        }
        $column->phpType = $this->getColumnPhpType($column);

        if (!$column->isPrimaryKey) {
            if ($info['dflt_value'] === 'null' || $info['dflt_value'] === '' || $info['dflt_value'] === null) {
                $column->defaultValue = null;
            } elseif ($column->type === 'timestamp' && $info['dflt_value'] === 'CURRENT_TIMESTAMP') {
                $column->defaultValue = new Expression('CURRENT_TIMESTAMP');
            } else {
                $value = trim($info['dflt_value'], "'\"");
                $column->defaultValue = $column->phpTypecast($value);
            }
        }

        return $column;
    }
protected function loadColumnSchema($info)
    {
        $column = $this->createColumnSchema();
        $column->name = $info['name'];
        $column->allowNull = !$info['notnull'];
        $column->isPrimaryKey = $info['pk'] != 0;

        $column->dbType = strtolower($info['type']);
        $column->unsigned = strpos($column->dbType, 'unsigned') !== false;

        $column->type = self::TYPE_STRING;
        if (preg_match('/^(\w+)(?:\(([^\)]+)\))?/', $column->dbType, $matches)) {
            $type = strtolower($matches[1]);
            if (isset($this->typeMap[$type])) {
                $column->type = $this->typeMap[$type];
            }

            if (!empty($matches[2])) {
                $values = explode(',', $matches[2]);
                $column->size = $column->precision = (int) $values[0];
                if (isset($values[1])) {
                    $column->scale = (int) $values[1];
                }
                if ($column->size === 1 && ($type === 'tinyint' || $type === 'bit')) {
                    $column->type = 'boolean';
                } elseif ($type === 'bit') {
                    if ($column->size > 32) {
                        $column->type = 'bigint';
                    } elseif ($column->size === 32) {
                        $column->type = 'integer';
                    }
                }
            }
        }
        $column->phpType = $this->getColumnPhpType($column);

        if (!$column->isPrimaryKey) {
            if ($info['dflt_value'] === 'null' || $info['dflt_value'] === '' || $info['dflt_value'] === null) {
                $column->defaultValue = null;
            } elseif ($column->type === 'timestamp' && $info['dflt_value'] === 'CURRENT_TIMESTAMP') {
                $column->defaultValue = new Expression('CURRENT_TIMESTAMP');
            } else {
                $value = trim($info['dflt_value'], "'\"");
                $column->defaultValue = $column->phpTypecast($value);
            }
        }

        return $column;
    }
protected function loadColumnSchema ( $ info ) { $ column = $ this -> createColumnSchema ( ) ; $ column -> name = $ info [ 'name' ] ; $ column -> allowNull = ! $ info [ 'notnull' ] ; $ column -> isPrimaryKey = $ info [ 'pk' ] != 0 ; $ column -> dbType = strtolower ( $ info [ 'type' ] ) ; $ column -> unsigned = strpos ( $ column -> dbType , 'unsigned' ) !== false ; $ column -> type = self :: TYPE_STRING ; if ( preg_match ( '/^(\w+)(?:\(([^\)]+)\))?/' , $ column -> dbType , $ matches ) ) { $ type = strtolower ( $ matches [ 1 ] ) ; if ( isset ( $ this -> typeMap [ $ type ] ) ) { $ column -> type = $ this -> typeMap [ $ type ] ; } if ( ! empty ( $ matches [ 2 ] ) ) { $ values = explode ( ',' , $ matches [ 2 ] ) ; $ column -> size = $ column -> precision = ( int ) $ values [ 0 ] ; if ( isset ( $ values [ 1 ] ) ) { $ column -> scale = ( int ) $ values [ 1 ] ; } if ( $ column -> size === 1 && ( $ type === 'tinyint' || $ type === 'bit' ) ) { $ column -> type = 'boolean' ; } elseif ( $ type === 'bit' ) { if ( $ column -> size > 32 ) { $ column -> type = 'bigint' ; } elseif ( $ column -> size === 32 ) { $ column -> type = 'integer' ; } } } } $ column -> phpType = $ this -> getColumnPhpType ( $ column ) ; if ( ! $ column -> isPrimaryKey ) { if ( $ info [ 'dflt_value' ] === 'null' || $ info [ 'dflt_value' ] === '' || $ info [ 'dflt_value' ] === null ) { $ column -> defaultValue = null ; } elseif ( $ column -> type === 'timestamp' && $ info [ 'dflt_value' ] === 'CURRENT_TIMESTAMP' ) { $ column -> defaultValue = new Expression ( 'CURRENT_TIMESTAMP' ) ; } else { $ value = trim ( $ info [ 'dflt_value' ] , "'\"" ) ; $ column -> defaultValue = $ column -> phpTypecast ( $ value ) ; } } return $ column ; }
Loads the column information into a [[ColumnSchema]] object.
@param array $info column information
@return ColumnSchema the column schema object
Loads the column information into a [[ ColumnSchema ]] object .