PHP Класс yii\db\ColumnSchemaBuilder

See SchemaBuilderTrait for more detailed description and usage examples.
С версии: 2.0.6
Автор: Vasenin Matvey ([email protected])
Наследование: extends yii\base\Object
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$categoryMap mapping of abstract column types (keys) to type categories (values).
$comment comment value of the column.
$db the current database connection. It is used mainly to escape strings safely when building the final column schema string.

Защищенные свойства (Protected)

Свойство Тип Описание
$after the column after which this column will be added.
$append SQL string to be appended to column schema definition.
$check the CHECK constraint for the column.
$default default value of the column.
$isFirst whether this column is to be inserted at the beginning of the table.
$isNotNull whether the column is or not nullable. If this is true, a NOT NULL constraint will be added. If this is false, a NULL constraint will be added.
$isUnique whether the column values should be unique. If this is true, a UNIQUE constraint will be added.
$isUnsigned whether the column values should be unsigned. If this is true, an UNSIGNED keyword will be added.
$length column size or precision definition. This is what goes into the parenthesis after the column type. This can be either a string, an integer or an array. If it is an array, the array values will be joined into a string separated by comma.
$type the column type definition such as INTEGER, VARCHAR, DATETIME, etc.

Открытые методы

Метод Описание
__construct ( string $type, integer | string | array $length = null, Connection $db = null, array $config = [] ) Create a column schema builder instance giving the type and value precision.
__toString ( ) : string Builds the full string for the column's schema
after ( string $after ) Adds an AFTER constraint to the column.
append ( string $sql ) Specify additional SQL to be appended to schema string.
check ( string $check ) Sets a CHECK constraint for the column.
comment ( string $comment ) Specifies the comment for column.
defaultExpression ( string $default ) Specify the default SQL expression for the column.
defaultValue ( mixed $default ) Specify the default value for the column.
first ( ) Adds an FIRST constraint to the column.
notNull ( ) Adds a NOT NULL constraint to the column.
null ( ) Adds a NULL constraint to the column
unique ( ) Adds a UNIQUE constraint to the column.
unsigned ( ) Marks column as unsigned.

Защищенные методы

Метод Описание
buildAfterString ( ) : string Builds the after constraint for the column. Defaults to unsupported.
buildAppendString ( ) : string Builds the custom string that's appended to column definition.
buildCheckString ( ) : string Builds the check constraint for the column.
buildCommentString ( ) : string Builds the comment specification for the column.
buildCompleteString ( string $format ) : string Returns the complete column definition from input format
buildDefaultString ( ) : string Builds the default value specification for the column.
buildFirstString ( ) : string Builds the first constraint for the column. Defaults to unsupported.
buildLengthString ( ) : string Builds the length/precision part of the column.
buildNotNullString ( ) : string Builds the not null constraint for the column.
buildUniqueString ( ) : string Builds the unique constraint for the column.
buildUnsignedString ( ) : string Builds the unsigned string for column. Defaults to unsupported.
getTypeCategory ( ) : string Returns the category of the column type.

Описание методов

__construct() публичный Метод

Create a column schema builder instance giving the type and value precision.
public __construct ( string $type, integer | string | array $length = null, Connection $db = null, array $config = [] )
$type string type of the column. See [[$type]].
$length integer | string | array length or precision of the column. See [[$length]].
$db Connection the current database connection. See [[$db]].
$config array name-value pairs that will be used to initialize the object properties

__toString() публичный Метод

Builds the full string for the column's schema
public __toString ( ) : string
Результат string

after() публичный Метод

Note: MySQL, Oracle and Cubrid support only.
С версии: 2.0.8
public after ( string $after )
$after string the column after which $this column will be added.

append() публичный Метод

Specify additional SQL to be appended to schema string.
С версии: 2.0.9
public append ( string $sql )
$sql string the SQL string to be appended.

buildAfterString() защищенный Метод

Builds the after constraint for the column. Defaults to unsupported.
С версии: 2.0.8
protected buildAfterString ( ) : string
Результат string a string containing the AFTER constraint.

buildAppendString() защищенный Метод

Builds the custom string that's appended to column definition.
С версии: 2.0.9
protected buildAppendString ( ) : string
Результат string custom string to append.

buildCheckString() защищенный Метод

Builds the check constraint for the column.
protected buildCheckString ( ) : string
Результат string a string containing the CHECK constraint.

buildCommentString() защищенный Метод

Builds the comment specification for the column.
С версии: 2.0.8
protected buildCommentString ( ) : string
Результат string a string containing the COMMENT keyword and the comment itself

buildCompleteString() защищенный Метод

Returns the complete column definition from input format
С версии: 2.0.8
protected buildCompleteString ( string $format ) : string
$format string the format of the definition.
Результат string a string containing the complete column definition.

buildDefaultString() защищенный Метод

Builds the default value specification for the column.
protected buildDefaultString ( ) : string
Результат string string with default value of column.

buildFirstString() защищенный Метод

Builds the first constraint for the column. Defaults to unsupported.
С версии: 2.0.8
protected buildFirstString ( ) : string
Результат string a string containing the FIRST constraint.

buildLengthString() защищенный Метод

Builds the length/precision part of the column.
protected buildLengthString ( ) : string
Результат string

buildNotNullString() защищенный Метод

Builds the not null constraint for the column.
protected buildNotNullString ( ) : string
Результат string returns 'NOT NULL' if [[isNotNull]] is true, 'NULL' if [[isNotNull]] is false or an empty string otherwise.

buildUniqueString() защищенный Метод

Builds the unique constraint for the column.
protected buildUniqueString ( ) : string
Результат string returns string 'UNIQUE' if [[isUnique]] is true, otherwise it returns an empty string.

buildUnsignedString() защищенный Метод

Builds the unsigned string for column. Defaults to unsupported.
С версии: 2.0.7
protected buildUnsignedString ( ) : string
Результат string a string containing UNSIGNED keyword.

check() публичный Метод

Sets a CHECK constraint for the column.
public check ( string $check )
$check string the SQL of the `CHECK` constraint to be added.

comment() публичный Метод

Specifies the comment for column.
С версии: 2.0.8
public comment ( string $comment )
$comment string the comment

defaultExpression() публичный Метод

Specify the default SQL expression for the column.
С версии: 2.0.7
public defaultExpression ( string $default )
$default string the default value expression.

defaultValue() публичный Метод

Specify the default value for the column.
public defaultValue ( mixed $default )
$default mixed the default value.

first() публичный Метод

Note: MySQL, Oracle and Cubrid support only.
С версии: 2.0.8
public first ( )

getTypeCategory() защищенный Метод

Returns the category of the column type.
С версии: 2.0.8
protected getTypeCategory ( ) : string
Результат string a string containing the column type category name.

notNull() публичный Метод

Adds a NOT NULL constraint to the column.
public notNull ( )

null() публичный Метод

Adds a NULL constraint to the column
С версии: 2.0.9
public null ( )

unique() публичный Метод

Adds a UNIQUE constraint to the column.
public unique ( )

unsigned() публичный Метод

Marks column as unsigned.
С версии: 2.0.7
public unsigned ( )

Описание свойств

$after защищенное свойство

the column after which this column will be added.
С версии: 2.0.8
protected $after

$append защищенное свойство

SQL string to be appended to column schema definition.
С версии: 2.0.9
protected $append

$categoryMap публичное свойство

mapping of abstract column types (keys) to type categories (values).
С версии: 2.0.8
public $categoryMap

$check защищенное свойство

the CHECK constraint for the column.
protected $check

$comment публичное свойство

comment value of the column.
С версии: 2.0.8
public $comment

$db публичное свойство

the current database connection. It is used mainly to escape strings safely when building the final column schema string.
С версии: 2.0.8
public $db

$default защищенное свойство

default value of the column.
protected $default

$isFirst защищенное свойство

whether this column is to be inserted at the beginning of the table.
С версии: 2.0.8
protected $isFirst

$isNotNull защищенное свойство

whether the column is or not nullable. If this is true, a NOT NULL constraint will be added. If this is false, a NULL constraint will be added.
protected $isNotNull

$isUnique защищенное свойство

whether the column values should be unique. If this is true, a UNIQUE constraint will be added.
protected $isUnique

$isUnsigned защищенное свойство

whether the column values should be unsigned. If this is true, an UNSIGNED keyword will be added.
С версии: 2.0.7
protected $isUnsigned

$length защищенное свойство

column size or precision definition. This is what goes into the parenthesis after the column type. This can be either a string, an integer or an array. If it is an array, the array values will be joined into a string separated by comma.
protected $length

$type защищенное свойство

the column type definition such as INTEGER, VARCHAR, DATETIME, etc.
protected $type