ColumnSchemaBuilder
API reference › yii › db › mssql › ColumnSchemaBuilder
ColumnSchemaBuilder is the schema builder for MSSQL databases.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$categoryMap | array | Mapping of abstract column types (keys) to type categories (values). | yii\ |
$checkValue read-only | string| | The CHECK constraint for the column. | ColumnSchemaBuilder |
$comment | string | Comment value of the column. Default: null. Available since 2.0.8. | yii\ |
$db | yii\ | The current database connection. Default: null. Available since 2.0.8. | yii\ |
$defaultValue read-only | string|yii\| | Default value of the column. | ColumnSchemaBuilder |
$typeCategoryMap static | array | Mapping of abstract column types (keys) to type categories (values). Default: [\. Available since 2.0.43. | yii\ |
$typeDefinition read-only | string | Abstract type plus optional length, for example string(255). Available since 22.0. | yii\ |
$after protected | string | The column after which this column will be added. Default: null. Available since 2.0.8. | yii\ |
$append protected | mixed | SQL string to be appended to column schema definition. Default: null. Available since 2.0.9. | yii\ |
$check protected | string | The CHECK constraint for the column. Default: null. | yii\ |
$default protected | mixed | Default value of the column. Default: null. | yii\ |
$format protected | Default: '{type}{length}{notnull}{unique}{default}{check}{append}'. | ColumnSchemaBuilder | |
$isFirst protected | bool | Whether this column is to be inserted at the beginning of the table. Default: null. Available since 2.0.8. | yii\ |
$isNotNull protected | bool| | Whether the column is or not nullable. Default: null. | yii\ |
$isUnique protected | bool | Whether the column values should be unique. Default: false. | yii\ |
$isUnsigned protected | bool | Whether the column values should be unsigned. Default: false. Available since 2.0.7. | yii\ |
$length protected | int| | Column size or precision definition. Default: null. | yii\ |
$type protected | string | The column type definition such as INTEGER, VARCHAR, DATETIME, etc. Default: null. | yii\ |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Create a column schema builder instance giving the type and value precision. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__toString() | Builds the full string for the column’s schema. | ColumnSchemaBuilder |
__unset() | Sets an object property to null. | yii\ |
after() | Adds an AFTER constraint to the column. | yii\ |
append() | Specify additional SQL to be appended to column definition. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
check() | Sets a CHECK constraint for the column. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
comment() | Specifies the comment for column. | yii\ |
defaultExpression() | Specify the default SQL expression for the column. | yii\ |
defaultValue() | Specify the default value for the column. | yii\ |
first() | Adds an FIRST constraint to the column. | yii\ |
getAppend() | Returns the raw SQL fragment appended to the column definition. | yii\ |
getCategoryMap() | yii\ | |
getCheck() | Returns the raw CHECK constraint expression of the column. | yii\ |
getCheckValue() | Get the Check value for constraint | ColumnSchemaBuilder |
getDefault() | Returns the raw default value of the column. | yii\ |
getDefaultValue() | Getting the Default value for constraint | ColumnSchemaBuilder |
getTypeDefinition() | Returns the abstract type together with its length or precision, without any constraint keywords. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | yii\ |
isNotNull() | Returns the nullability state of the column as a tri-state value. | yii\ |
isUnique() | Returns whether the column carries a UNIQUE constraint. | yii\ |
notNull() | Adds a NOT NULL constraint to the column. | yii\ |
null() | Adds a NULL constraint to the column. | yii\ |
setAlterColumnFormat() | Changes default format string to MSSQL ALTER COMMAND. | ColumnSchemaBuilder |
setCategoryMap() | yii\ | |
unique() | Adds a UNIQUE constraint to the column. | yii\ |
unsigned() | Marks column as unsigned. | yii\ |
buildAfterString() protected | Builds the after constraint for the column. Defaults to unsupported. | yii\ |
buildAppendString() protected | Builds the custom string that’s appended to column definition. | yii\ |
buildCheckString() protected | Builds the check constraint for the column. | yii\ |
buildCommentString() protected | Builds the comment specification for the column. | yii\ |
buildCompleteString() protected | Returns the complete column definition from input format. | yii\ |
buildDefaultString() protected | Builds the default value specification for the column. | yii\ |
buildDefaultValue() protected | Return the default value for the column. | yii\ |
buildFirstString() protected | Builds the first constraint for the column. Defaults to unsupported. | yii\ |
buildLengthString() protected | Builds the length/precision part of the column. | yii\ |
buildNotNullString() protected | Builds the not null constraint for the column. | yii\ |
buildUniqueString() protected | Builds the unique constraint for the column. | yii\ |
buildUnsignedString() protected | Builds the unsigned string for column. Defaults to unsupported. | yii\ |
getTypeCategory() protected | Returns the category of the column type. | yii\ |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
CATEGORY_PK | 'pk' | yii\ | |
CATEGORY_STRING | 'string' | yii\ | |
CATEGORY_NUMERIC | 'numeric' | yii\ | |
CATEGORY_TIME | 'time' | yii\ | |
CATEGORY_OTHER | 'other' | yii\ |
Method details
Section titled “Method details”__toString()
Section titled “__toString() ”public function __toString(): stringBuilds the full string for the column’s schema.
Returns
string
getCheckValue()
Section titled “getCheckValue() ”public function getCheckValue(): string|nullGet the Check value for constraint
Returns
string|null: The CHECK constraint for the column.
getDefaultValue()
Section titled “getDefaultValue() ”public function getDefaultValue(): string|yii\db\Expression|nullGetting the Default value for constraint
Returns
string|yii\db\Expression|null: Default value of the column.
setAlterColumnFormat()
Section titled “setAlterColumnFormat() ”public function setAlterColumnFormat(): mixedChanges default format string to MSSQL ALTER COMMAND.
Returns
mixed