Class yii\db\ColumnSchema
ColumnSchema 类描述了数据库表中的列的元数据。
公共属性
| 属性 | 类型 | 描述 | 被定义在 |
|---|---|---|---|
| $allowNull | boolean | 此列是否可以为空。 | yii\db\ColumnSchema |
| $autoIncrement | boolean | 此列是否自增长 | yii\db\ColumnSchema |
| $comment | string | 此列的注释。并非所有的 DBMS 都支持。 | yii\db\ColumnSchema |
| $dbType | string | 此列的 DB 类型。可能的 DB 类型因 DBMS 的类型而异。 | yii\db\ColumnSchema |
| $defaultValue | mixed | 列的默认值 | yii\db\ColumnSchema |
| $enumValues | array | 可枚举值。仅当列声明为可枚举类型时才设置此值。 | yii\db\ColumnSchema |
| $isPrimaryKey | boolean | 此列是否为主键 | yii\db\ColumnSchema |
| $name | string | 此列的名称(不带引号)。 | yii\db\ColumnSchema |
| $phpType | string | 此列的 PHP 类型。可能的 PHP 类型包括:
string,boolean,integer,double,array。 |
yii\db\ColumnSchema |
| $precision | integer | 列数据的精度,如果为数字。 | yii\db\ColumnSchema |
| $scale | integer | 列数据的小数位数,如果为数字。 | yii\db\ColumnSchema |
| $size | integer | 列的显示大小。 | yii\db\ColumnSchema |
| $type | string | 此列的抽象类型。可能的抽象类型包括: char,string,text,boolean,smallint,integer,bigint,float,decimal,datetime, timestamp,time,date,binary 和 money。 | yii\db\ColumnSchema |
| $unsigned | boolean | 列是否为无符号。
仅在 $type 为 smallint,integer 或 bigint 有效。 |
yii\db\ColumnSchema |
公共方法
| 方法 | 描述 | 被定义在 |
|---|---|---|
| __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() | 根据 $type 和 $dbType 转换为输入值,以便在数据库查询中使用。 如果值为 null 或为 yii\db\Expression,则不会转换。 | 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() | 从数据库检索后,根据 $phpType 转换为输入值。 如果值为空或为 yii\db\Expression,则不会转换。 | yii\db\ColumnSchema |
受保护的方法
| 方法 | 描述 | 被定义在 |
|---|---|---|
| typecast() | 从数据库检索后,根据 $phpType 转换为输入值。 如果值为 null 或 yii\db\Expression,则不会转换。 | yii\db\ColumnSchema |
属性详情
此列是否可以为空。
此列是否自增长
此列的注释。并非所有的 DBMS 都支持。
此列的 DB 类型。可能的 DB 类型因 DBMS 的类型而异。
列的默认值
可枚举值。仅当列声明为可枚举类型时才设置此值。
此列是否为主键
此列的名称(不带引号)。
此列的 PHP 类型。可能的 PHP 类型包括:
string,boolean,integer,double,array。
列数据的精度,如果为数字。
列数据的小数位数,如果为数字。
列的显示大小。
此列的抽象类型。可能的抽象类型包括: char,string,text,boolean,smallint,integer,bigint,float,decimal,datetime, timestamp,time,date,binary 和 money。
列是否为无符号。
仅在 $type 为 smallint,integer 或 bigint 有效。
方法详情
根据 $type 和 $dbType 转换为输入值,以便在数据库查询中使用。 如果值为 null 或为 yii\db\Expression,则不会转换。
| public mixed dbTypecast($value) | ||
| $value | mixed | 输入值 |
| return | mixed | 转换的值。这也可以是一个数组,其中值作为第一个元素, PDO 类型作为第二个元素。 |
|---|---|---|
从数据库检索后,根据 $phpType 转换为输入值。 如果值为空或为 yii\db\Expression,则不会转换。
| public mixed phpTypecast($value) | ||
| $value | mixed | 输入值 |
| return | mixed | 转换后的值 |
|---|---|---|
从数据库检索后,根据 $phpType 转换为输入值。 如果值为 null 或 yii\db\Expression,则不会转换。
| protected mixed typecast($value) | ||
| $value | mixed | 输入值 |
| return | mixed | 转换的值 |
|---|---|---|