ColumnSchema
API reference › yii › db › sqlite › ColumnSchema
Represents the metadata of a column in a SQLite database table.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$allowNull | bool | Whether this column can be null. Default: false. | yii\ |
$autoIncrement | bool | Whether this column is auto-incremental Default: false. | yii\ |
$comment | string| | Comment of this column. Default: null. | yii\ |
$dbType | string | The DB type of this column. Default: ''. | yii\ |
$defaultValue | mixed | Default value of this column Default: null. | yii\ |
$enumValues | array| | Enumerable values. Default: null. | yii\ |
$isPrimaryKey | bool| | Whether this column is a primary key Default: null. | yii\ |
$name | string | Name of this column (without quotes). Default: ''. | yii\ |
$phpType | string | The PHP type of this column. Default: ''. | yii\ |
$precision | int| | Precision of the column data, if it is numeric. Default: null. | yii\ |
$scale | int| | Scale of the column data, if it is numeric. Default: null. | yii\ |
$size | int| | Display size of the column. Default: null. | yii\ |
$type | string | Abstract type of this column. Default: ''. | yii\ |
$unsigned | bool | Whether this column is unsigned. Default: false. | yii\ |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | 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\ |
__unset() | Sets an object property to null. | 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\ |
className() static | Returns the fully qualified name of this class. | yii\ |
dbTypecast() | Converts the input value according to $type and $dbType for use in a db query. | yii\ |
defaultPhpTypecast() | Converts a SQLite column default value to its PHP representation. | ColumnSchema |
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\ |
isType() | Returns whether this column uses the given abstract type. | yii\ |
phpTypecast() | Converts the input value according to $phpType after retrieval from the database. | yii\ |
typecast() protected | Converts the input value according to $phpType after retrieval from the database. | yii\ |
Method details
Section titled “Method details”defaultPhpTypecast()
Section titled “defaultPhpTypecast() ”public function defaultPhpTypecast(mixed $value): mixedConverts a SQLite column default value to its PHP representation.
Handles SQLite-specific default formats reported by PRAGMA table_info:
null, empty strings, and bare or parenthesizedNULLtonull.CURRENT_DATE,CURRENT_TIME, andCURRENT_TIMESTAMPtoExpression.- single, double, backtick, or bracket-quoted string literals to their unquoted PHP value.
- signed decimal and scientific numeric literals through
ColumnSchema::phpTypecast(). TRUEandFALSEthroughColumnSchema::phpTypecast()as1and0respectively.- bareword defaults to their literal text value, matching SQLite’s non-parenthesized
DEFAULT wordbehavior. - everything else to an executable
Expression, including functions, operators, BLOB literals, and hexadecimal integers whose meaning is only preserved when parsed as SQL text.
Branch order is significant: CURRENT_* and TRUE/FALSE must precede the bareword fallthrough, or they would
reflect as string literals. PRAGMA table_info strips one outer parenthesis level; paren-tolerant branches exist
only for literals that are also legal inside a parenthesized default expression.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Default value in SQLite dflt_value format. |
Returns
mixed: Converted value.
Since
22.0