没有命名空间的类 yii yii\base yii\behaviors yii\caching yii\captcha yii\console yii\console\controllers yii\console\widgets yii\data yii\db yii\db\conditions yii\db\cubrid yii\db\cubrid\conditions yii\db\mssql yii\db\mssql\conditions yii\db\mysql yii\db\oci yii\db\oci\conditions yii\db\pgsql yii\db\sqlite yii\db\sqlite\conditions yii\di yii\filters yii\filters\auth yii\grid yii\helpers yii\i18n yii\log yii\mail yii\mutex yii\rbac yii\rest yii\test yii\validators yii\web yii\widgets

Class yii\db\ColumnSchemaBuilder

继承yii\db\ColumnSchemaBuilder » yii\base\BaseObject
实现yii\base\Configurable
子类yii\db\cubrid\ColumnSchemaBuilder, yii\db\mysql\ColumnSchemaBuilder, yii\db\oci\ColumnSchemaBuilder, yii\db\sqlite\ColumnSchemaBuilder
可用版本自2.0.6
源码 https://github.com/yiichina/yii2/blob/api/framework/db/ColumnSchemaBuilder.php

ColumnSchemaBuilder helps to define database schema types using a PHP interface.

See yii\db\SchemaBuilderTrait for more detailed description and usage examples.

公共属性

隐藏继承的属性

属性类型描述被定义在
$categoryMap array Mapping of abstract column types (keys) to type categories (values). yii\db\ColumnSchemaBuilder
$comment string Comment value of the column. yii\db\ColumnSchemaBuilder
$db yii\db\Connection The current database connection. yii\db\ColumnSchemaBuilder

受保护的属性

隐藏继承的属性

属性类型描述被定义在
$after string The column after which this column will be added. yii\db\ColumnSchemaBuilder
$append mixed SQL string to be appended to column schema definition. yii\db\ColumnSchemaBuilder
$check string The CHECK constraint for the column. yii\db\ColumnSchemaBuilder
$default mixed Default value of the column. yii\db\ColumnSchemaBuilder
$isFirst boolean Whether this column is to be inserted at the beginning of the table. yii\db\ColumnSchemaBuilder
$isNotNull boolean|null Whether the column is or not nullable. yii\db\ColumnSchemaBuilder
$isUnique boolean Whether the column values should be unique. yii\db\ColumnSchemaBuilder
$isUnsigned boolean Whether the column values should be unsigned. yii\db\ColumnSchemaBuilder
$length integer|string|array Column size or precision definition. yii\db\ColumnSchemaBuilder
$type string The column type definition such as INTEGER, VARCHAR, DATETIME, etc. yii\db\ColumnSchemaBuilder

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. yii\base\BaseObject
__construct() Create a column schema builder instance giving the type and value precision. yii\db\ColumnSchemaBuilder
__get() Returns the value of an object property. yii\base\BaseObject
__isset() Checks if a property is set, i.e. defined and not null. yii\base\BaseObject
__set() Sets value of an object property. yii\base\BaseObject
__toString() Builds the full string for the column's schema. yii\db\ColumnSchemaBuilder
__unset() Sets an object property to null. yii\base\BaseObject
after() Adds an AFTER constraint to the column. yii\db\ColumnSchemaBuilder
append() Specify additional SQL to be appended to column definition. yii\db\ColumnSchemaBuilder
canGetProperty() Returns a value indicating whether a property can be read. yii\base\BaseObject
canSetProperty() Returns a value indicating whether a property can be set. yii\base\BaseObject
check() Sets a CHECK constraint for the column. yii\db\ColumnSchemaBuilder
className() Returns the fully qualified name of this class. yii\base\BaseObject
comment() Specifies the comment for column. yii\db\ColumnSchemaBuilder
defaultExpression() Specify the default SQL expression for the column. yii\db\ColumnSchemaBuilder
defaultValue() Specify the default value for the column. yii\db\ColumnSchemaBuilder
first() Adds an FIRST constraint to the column. yii\db\ColumnSchemaBuilder
hasMethod() Returns a value indicating whether a method is defined. yii\base\BaseObject
hasProperty() Returns a value indicating whether a property is defined. yii\base\BaseObject
init() Initializes the object. yii\base\BaseObject
notNull() Adds a NOT NULL constraint to the column. yii\db\ColumnSchemaBuilder
null() Adds a NULL constraint to the column. yii\db\ColumnSchemaBuilder
unique() Adds a UNIQUE constraint to the column. yii\db\ColumnSchemaBuilder
unsigned() Marks column as unsigned. yii\db\ColumnSchemaBuilder

受保护的方法

隐藏继承的方法

方法描述被定义在
buildAfterString() Builds the after constraint for the column. Defaults to unsupported. yii\db\ColumnSchemaBuilder
buildAppendString() Builds the custom string that's appended to column definition. yii\db\ColumnSchemaBuilder
buildCheckString() Builds the check constraint for the column. yii\db\ColumnSchemaBuilder
buildCommentString() Builds the comment specification for the column. yii\db\ColumnSchemaBuilder
buildCompleteString() Returns the complete column definition from input format. yii\db\ColumnSchemaBuilder
buildDefaultString() Builds the default value specification for the column. yii\db\ColumnSchemaBuilder
buildFirstString() Builds the first constraint for the column. Defaults to unsupported. yii\db\ColumnSchemaBuilder
buildLengthString() Builds the length/precision part of the column. yii\db\ColumnSchemaBuilder
buildNotNullString() Builds the not null constraint for the column. yii\db\ColumnSchemaBuilder
buildUniqueString() Builds the unique constraint for the column. yii\db\ColumnSchemaBuilder
buildUnsignedString() Builds the unsigned string for column. Defaults to unsupported. yii\db\ColumnSchemaBuilder
getTypeCategory() Returns the category of the column type. yii\db\ColumnSchemaBuilder

常量

隐藏继承的常量

常量描述被定义在
CATEGORY_NUMERIC 'numeric' yii\db\ColumnSchemaBuilder
CATEGORY_OTHER 'other' yii\db\ColumnSchemaBuilder
CATEGORY_PK 'pk' yii\db\ColumnSchemaBuilder
CATEGORY_STRING 'string' yii\db\ColumnSchemaBuilder
CATEGORY_TIME 'time' yii\db\ColumnSchemaBuilder

属性详情

$after 受保护 属性 (自版本 2.0.8 可用)

The column after which this column will be added.

protected string $after null
$append 受保护 属性 (自版本 2.0.9 可用)

SQL string to be appended to column schema definition.

protected mixed $append null
$categoryMap 公共 属性 (自版本 2.0.8 可用)

Mapping of abstract column types (keys) to type categories (values).

public array $categoryMap = [\yii\db\Schema::TYPE_PK => self::CATEGORY_PK, \yii\db\Schema::TYPE_UPK => self::CATEGORY_PK, \yii\db\Schema::TYPE_BIGPK => self::CATEGORY_PK, \yii\db\Schema::TYPE_UBIGPK => self::CATEGORY_PK, \yii\db\Schema::TYPE_CHAR => self::CATEGORY_STRING, \yii\db\Schema::TYPE_STRING => self::CATEGORY_STRING, \yii\db\Schema::TYPE_TEXT => self::CATEGORY_STRING, \yii\db\Schema::TYPE_TINYINT => self::CATEGORY_NUMERIC, \yii\db\Schema::TYPE_SMALLINT => self::CATEGORY_NUMERIC, \yii\db\Schema::TYPE_INTEGER => self::CATEGORY_NUMERIC, \yii\db\Schema::TYPE_BIGINT => self::CATEGORY_NUMERIC, \yii\db\Schema::TYPE_FLOAT => self::CATEGORY_NUMERIC, \yii\db\Schema::TYPE_DOUBLE => self::CATEGORY_NUMERIC, \yii\db\Schema::TYPE_DECIMAL => self::CATEGORY_NUMERIC, \yii\db\Schema::TYPE_DATETIME => self::CATEGORY_TIME, \yii\db\Schema::TYPE_TIMESTAMP => self::CATEGORY_TIME, \yii\db\Schema::TYPE_TIME => self::CATEGORY_TIME, \yii\db\Schema::TYPE_DATE => self::CATEGORY_TIME, \yii\db\Schema::TYPE_BINARY => self::CATEGORY_OTHER, \yii\db\Schema::TYPE_BOOLEAN => self::CATEGORY_NUMERIC, \yii\db\Schema::TYPE_MONEY => self::CATEGORY_NUMERIC]
$check 受保护 属性

The CHECK constraint for the column.

protected string $check null
$comment 公共 属性 (自版本 2.0.8 可用)

Comment value of the column.

public string $comment null
$db 公共 属性 (自版本 2.0.8 可用)

The current database connection. It is used mainly to escape strings safely when building the final column schema string.

public yii\db\Connection $db null
$default 受保护 属性

Default value of the column.

protected mixed $default null
$isFirst 受保护 属性 (自版本 2.0.8 可用)

Whether this column is to be inserted at the beginning of the table.

protected boolean $isFirst null
$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 boolean|null $isNotNull null
$isUnique 受保护 属性

Whether the column values should be unique. If this is true, a UNIQUE constraint will be added.

protected boolean $isUnique false
$isUnsigned 受保护 属性 (自版本 2.0.7 可用)

Whether the column values should be unsigned. If this is true, an UNSIGNED keyword will be added.

protected boolean $isUnsigned false
$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 integer|string|array $length null
$type 受保护 属性

The column type definition such as INTEGER, VARCHAR, DATETIME, etc.

protected string $type null

方法详情

__construct() 公共 方法

Create a column schema builder instance giving the type and value precision.

public void __construct($type, $length null, $db null, $config = [])
$type string

Type of the column. See $type.

$length integer|string|array

Length or precision of the column. See $length.

$db yii\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 string __toString()
after() 公共 方法 (自版本 2.0.8 可用)

Adds an AFTER constraint to the column.

Note: MySQL, Oracle and Cubrid support only.

public $this after($after)
$after string

The column after which $this column will be added.

append() 公共 方法 (自版本 2.0.9 可用)

Specify additional SQL to be appended to column definition.

Position modifiers will be appended after column definition in databases that support them.

public $this append($sql)
$sql string

The SQL string to be appended.

buildAfterString() 受保护 方法 (自版本 2.0.8 可用)

Builds the after constraint for the column. Defaults to unsupported.

protected string buildAfterString()
return string

A string containing the AFTER constraint.

buildAppendString() 受保护 方法 (自版本 2.0.9 可用)

Builds the custom string that's appended to column definition.

protected string buildAppendString()
return string

Custom string to append.

buildCheckString() 受保护 方法

Builds the check constraint for the column.

protected string buildCheckString()
return string

A string containing the CHECK constraint.

buildCommentString() 受保护 方法 (自版本 2.0.8 可用)

Builds the comment specification for the column.

protected string buildCommentString()
return string

A string containing the COMMENT keyword and the comment itself

buildCompleteString() 受保护 方法 (自版本 2.0.8 可用)

Returns the complete column definition from input format.

protected string buildCompleteString($format)
$format string

The format of the definition.

return string

A string containing the complete column definition.

buildDefaultString() 受保护 方法

Builds the default value specification for the column.

protected string buildDefaultString()
return string

String with default value of column.

buildFirstString() 受保护 方法 (自版本 2.0.8 可用)

Builds the first constraint for the column. Defaults to unsupported.

protected string buildFirstString()
return string

A string containing the FIRST constraint.

buildLengthString() 受保护 方法

Builds the length/precision part of the column.

protected string buildLengthString()
buildNotNullString() 受保护 方法

Builds the not null constraint for the column.

protected string buildNotNullString()
return 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 string buildUniqueString()
return string

Returns string 'UNIQUE' if $isUnique is true, otherwise it returns an empty string.

buildUnsignedString() 受保护 方法 (自版本 2.0.7 可用)

Builds the unsigned string for column. Defaults to unsupported.

protected string buildUnsignedString()
return string

A string containing UNSIGNED keyword.

check() 公共 方法

Sets a CHECK constraint for the column.

public $this check($check)
$check string

The SQL of the CHECK constraint to be added.

comment() 公共 方法 (自版本 2.0.8 可用)

Specifies the comment for column.

public $this comment($comment)
$comment string

The comment

defaultExpression() 公共 方法 (自版本 2.0.7 可用)

Specify the default SQL expression for the column.

public $this defaultExpression($default)
$default string

The default value expression.

defaultValue() 公共 方法

Specify the default value for the column.

public $this defaultValue($default)
$default mixed

The default value.

first() 公共 方法 (自版本 2.0.8 可用)

Adds an FIRST constraint to the column.

Note: MySQL, Oracle and Cubrid support only.

public $this first()
getTypeCategory() 受保护 方法 (自版本 2.0.8 可用)

Returns the category of the column type.

protected string getTypeCategory()
return string

A string containing the column type category name.

notNull() 公共 方法

Adds a NOT NULL constraint to the column.

public $this notNull()
null() 公共 方法 (自版本 2.0.9 可用)

Adds a NULL constraint to the column.

public $this null()
unique() 公共 方法

Adds a UNIQUE constraint to the column.

public $this unique()
unsigned() 公共 方法 (自版本 2.0.7 可用)

Marks column as unsigned.

public $this unsigned()