Skip to content
PHP Ecosystem
Explore

ColumnSchemaBuilder

API reference › yii › db › mysql › ColumnSchemaBuilder

ColumnSchemaBuilder is the schema builder for MySQL databases.

PropertyTypeDescriptionDefined by
$categoryMaparrayMapping of abstract column types (keys) to type categories (values).yii\db\ColumnSchemaBuilder
$commentstringComment value of the column. Default: null. Available since 2.0.8.yii\db\ColumnSchemaBuilder
$dbyii\db\ConnectionThe current database connection. Default: null. Available since 2.0.8.yii\db\ColumnSchemaBuilder
$typeCategoryMap staticarrayMapping of abstract column types (keys) to type categories (values). Default: [\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]. Available since 2.0.43.yii\db\ColumnSchemaBuilder
$typeDefinition read-onlystringAbstract type plus optional length, for example string(255). Available since 22.0.yii\db\ColumnSchemaBuilder
$after protectedstringThe column after which this column will be added. Default: null. Available since 2.0.8.yii\db\ColumnSchemaBuilder
$append protectedmixedSQL string to be appended to column schema definition. Default: null. Available since 2.0.9.yii\db\ColumnSchemaBuilder
$check protectedstringThe CHECK constraint for the column. Default: null.yii\db\ColumnSchemaBuilder
$default protectedmixedDefault value of the column. Default: null.yii\db\ColumnSchemaBuilder
$isFirst protectedboolWhether this column is to be inserted at the beginning of the table. Default: null. Available since 2.0.8.yii\db\ColumnSchemaBuilder
$isNotNull protectedbool|nullWhether the column is or not nullable. Default: null.yii\db\ColumnSchemaBuilder
$isUnique protectedboolWhether the column values should be unique. Default: false.yii\db\ColumnSchemaBuilder
$isUnsigned protectedboolWhether the column values should be unsigned. Default: false. Available since 2.0.7.yii\db\ColumnSchemaBuilder
$length protectedint|string|arrayColumn size or precision definition. Default: null.yii\db\ColumnSchemaBuilder
$type protectedstringThe column type definition such as INTEGER, VARCHAR, DATETIME, etc. Default: null.yii\db\ColumnSchemaBuilder
MethodDescriptionDefined by
__construct()Create a column schema builder instance giving the type and value precision.yii\db\ColumnSchemaBuilder
__call()Calls the named method which is not a class method.yii\base\BaseObject
__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.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() staticReturns 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
getAppend()Returns the raw SQL fragment appended to the column definition.yii\db\ColumnSchemaBuilder
getCategoryMap()yii\db\ColumnSchemaBuilder
getCheck()Returns the raw CHECK constraint expression of the column.yii\db\ColumnSchemaBuilder
getDefault()Returns the raw default value of the column.yii\db\ColumnSchemaBuilder
getTypeDefinition()Returns the abstract type together with its length or precision, without any constraint keywords.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
isNotNull()Returns the nullability state of the column as a tri-state value.yii\db\ColumnSchemaBuilder
isUnique()Returns whether the column carries a UNIQUE constraint.yii\db\ColumnSchemaBuilder
notNull()Adds a NOT NULL constraint to the column.yii\db\ColumnSchemaBuilder
null()Adds a NULL constraint to the column.yii\db\ColumnSchemaBuilder
setCategoryMap()yii\db\ColumnSchemaBuilder
unique()Adds a UNIQUE constraint to the column.yii\db\ColumnSchemaBuilder
unsigned()Marks column as unsigned.yii\db\ColumnSchemaBuilder
buildAfterString() protectedBuilds the after constraint for the column. Defaults to unsupported.ColumnSchemaBuilder
buildAppendString() protectedBuilds the custom string that’s appended to column definition.yii\db\ColumnSchemaBuilder
buildCheckString() protectedBuilds the check constraint for the column.yii\db\ColumnSchemaBuilder
buildCommentString() protectedBuilds the comment specification for the column.ColumnSchemaBuilder
buildCompleteString() protectedReturns the complete column definition from input format.yii\db\ColumnSchemaBuilder
buildDefaultString() protectedBuilds the default value specification for the column.yii\db\ColumnSchemaBuilder
buildDefaultValue() protectedReturn the default value for the column.yii\db\ColumnSchemaBuilder
buildFirstString() protectedBuilds the first constraint for the column. Defaults to unsupported.ColumnSchemaBuilder
buildLengthString() protectedBuilds the length/precision part of the column.yii\db\ColumnSchemaBuilder
buildNotNullString() protectedBuilds the not null constraint for the column.yii\db\ColumnSchemaBuilder
buildUniqueString() protectedBuilds the unique constraint for the column.yii\db\ColumnSchemaBuilder
buildUnsignedString() protectedBuilds the unsigned string for column. Defaults to unsupported.ColumnSchemaBuilder
getTypeCategory() protectedReturns the category of the column type.yii\db\ColumnSchemaBuilder
public function __toString(): string

Builds the full string for the column’s schema.

Returns

string

protected function buildAfterString(): string

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

Returns

string: A string containing the AFTER constraint.

Since

2.0.8

protected function buildCommentString(): string

Builds the comment specification for the column.

Returns

string: A string containing the COMMENT keyword and the comment itself

Since

2.0.8

protected function buildFirstString(): string

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

Returns

string: A string containing the FIRST constraint.

Since

2.0.8

protected function buildUnsignedString(): string

Builds the unsigned string for column. Defaults to unsupported.

Returns

string: A string containing UNSIGNED keyword.

Since

2.0.7