Class yii\db\ColumnSchema

Inheritanceyii\db\ColumnSchema » yii\base\BaseObject
Implementsyii\base\Configurable
Subclassesyii\db\mysql\ColumnSchema, yii\db\pgsql\ColumnSchema
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\BaseObject
__construct() Constructor. 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
__unset() Sets an object property to null. yii\base\BaseObject
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
className() Returns the fully qualified name of this class. yii\base\BaseObject
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\BaseObject
hasProperty() Returns a value indicating whether a property is defined. yii\base\BaseObject
init() Initializes the object. yii\base\BaseObject
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.

public boolean $allowNull null
$autoIncrement public property

Whether this column is auto-incremental

public boolean $autoIncrement false
$comment public property

Comment of this column. Not all DBMS support this.

public string $comment null
$dbType public property

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

public string $dbType null
$defaultValue public property

Default value of this column

public mixed $defaultValue null
$enumValues public property

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

public array $enumValues null
$isPrimaryKey public property

Whether this column is a primary key

public boolean $isPrimaryKey null
$name public property

Name of this column (without quotes).

public string $name null
$phpType public property

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

public string $phpType null
$precision public property

Precision of the column data, if it is numeric.

public integer $precision null
$scale public property

Scale of the column data, if it is numeric.

public integer $scale null
$size public property

Display size of the column.

public integer $size null
$type public property

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

public string $type null
$unsigned public property

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

public boolean $unsigned null

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.

public 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.

public 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.

protected mixed typecast ( $value )
$value mixed

Input value

return mixed

Converted value