Class yii\db\ColumnSchema

Inheritanceyii\db\ColumnSchema » yii\base\Object
Implementsyii\base\Configurable
Available since version2.0
Source Code https://github.com/yiisoft/yii2/blob/master/framework/db/ColumnSchema.php

ColumnSchema class describes the metadata of a column in a database table.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$allowNull boolean Whether this column can be null. yii\db\ColumnSchema
$autoIncrement boolean Whether this column is auto-incremental yii\db\ColumnSchema
$comment string Comment of this column. yii\db\ColumnSchema
$dbType string The DB type of this column. yii\db\ColumnSchema
$defaultValue mixed Default value of this column yii\db\ColumnSchema
$enumValues array Enumerable values. yii\db\ColumnSchema
$isPrimaryKey boolean Whether this column is a primary key yii\db\ColumnSchema
$name string Name of this column (without quotes). yii\db\ColumnSchema
$phpType string The PHP type of this column. yii\db\ColumnSchema
$precision integer Precision of the column data, if it is numeric. yii\db\ColumnSchema
$scale integer Scale of the column data, if it is numeric. yii\db\ColumnSchema
$size integer Display size of the column. yii\db\ColumnSchema
$type string Abstract type of this column. yii\db\ColumnSchema
$unsigned boolean Whether this column is unsigned. yii\db\ColumnSchema

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Returns the value of an object property. yii\base\Object
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Sets value of an object property. yii\base\Object
__unset() Sets an object property to null. yii\base\Object
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Object
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Object
className() Returns the fully qualified name of this class. yii\base\Object
dbTypecast() Converts the input value according to $type and $dbType for use in a db query. yii\db\ColumnSchema
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. yii\base\Object
phpTypecast() Converts the input value according to $phpType after retrieval from the database. yii\db\ColumnSchema

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
typecast() Converts the input value according to $phpType after retrieval from the database. yii\db\ColumnSchema

Property Details

$allowNull public property

Whether this column can be null.

$autoIncrement public property

Whether this column is auto-incremental

$comment public property

Comment of this column. Not all DBMS support this.

$dbType public property
string $dbType null

The DB type of this column. Possible DB types vary according to the type of DBMS.

$defaultValue public property
mixed $defaultValue null

Default value of this column

$enumValues public property

Enumerable values. This is set only if the column is declared to be an enumerable type.

$isPrimaryKey public property

Whether this column is a primary key

$name public property
string $name null

Name of this column (without quotes).

$phpType public property

The PHP type of this column. Possible PHP types include: string, boolean, integer, double.

$precision public property

Precision of the column data, if it is numeric.

$scale public property
integer $scale null

Scale of the column data, if it is numeric.

$size public property
integer $size null

Display size of the column.

$type public property
string $type null

Abstract type of this column. Possible abstract types include: string, text, boolean, smallint, integer, bigint, float, decimal, datetime, timestamp, time, date, binary, and money.

$unsigned public property

Whether this column is unsigned. This is only meaningful when $type is smallint, integer or bigint.

Method Details

dbTypecast() public method

Converts the input value according to $type and $dbType for use in a db query.

If the value is null or an yii\db\Expression, it will not be converted.

mixed dbTypecast$value )
$value mixed

Input value

return mixed

Converted value. This may also be an array containing the value as the first element and the PDO type as the second element.

phpTypecast() public method

Converts the input value according to $phpType after retrieval from the database.

If the value is null or an yii\db\Expression, it will not be converted.

mixed phpTypecast$value )
$value mixed

Input value

return mixed

Converted value

typecast() protected method (available since version 2.0.3)

Converts the input value according to $phpType after retrieval from the database.

If the value is null or an yii\db\Expression, it will not be converted.

mixed typecast$value )
$value mixed

Input value

return mixed

Converted value