Skip to content
PHP Ecosystem
Explore

ColumnSchema

API reference › yii › db › sqlite › ColumnSchema

classyii\db\sqlite\ColumnSchema
Extendsyii\db\ColumnSchema » yii\base\BaseObject
Implementsyii\base\Configurable
Since22.0
Sourceframework/db/sqlite/ColumnSchema.php

Represents the metadata of a column in a SQLite database table.

PropertyTypeDescriptionDefined by
$allowNullboolWhether this column can be null. Default: false.yii\db\ColumnSchema
$autoIncrementboolWhether this column is auto-incremental Default: false.yii\db\ColumnSchema
$commentstring|nullComment of this column. Default: null.yii\db\ColumnSchema
$dbTypestringThe DB type of this column. Default: ''.yii\db\ColumnSchema
$defaultValuemixedDefault value of this column Default: null.yii\db\ColumnSchema
$enumValuesarray|nullEnumerable values. Default: null.yii\db\ColumnSchema
$isPrimaryKeybool|nullWhether this column is a primary key Default: null.yii\db\ColumnSchema
$namestringName of this column (without quotes). Default: ''.yii\db\ColumnSchema
$phpTypestringThe PHP type of this column. Default: ''.yii\db\ColumnSchema
$precisionint|nullPrecision of the column data, if it is numeric. Default: null.yii\db\ColumnSchema
$scaleint|nullScale of the column data, if it is numeric. Default: null.yii\db\ColumnSchema
$sizeint|nullDisplay size of the column. Default: null.yii\db\ColumnSchema
$typestringAbstract type of this column. Default: ''.yii\db\ColumnSchema
$unsignedboolWhether this column is unsigned. Default: false.yii\db\ColumnSchema
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.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() staticReturns 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
defaultPhpTypecast()Converts a SQLite column default value to its PHP representation.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
isType()Returns whether this column uses the given abstract type.yii\db\ColumnSchema
phpTypecast()Converts the input value according to $phpType after retrieval from the database.yii\db\ColumnSchema
typecast() protectedConverts the input value according to $phpType after retrieval from the database.yii\db\ColumnSchema
public function defaultPhpTypecast(mixed $value): mixed

Converts 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 parenthesized NULL to null.
  • CURRENT_DATE, CURRENT_TIME, and CURRENT_TIMESTAMP to Expression.
  • single, double, backtick, or bracket-quoted string literals to their unquoted PHP value.
  • signed decimal and scientific numeric literals through ColumnSchema::phpTypecast().
  • TRUE and FALSE through ColumnSchema::phpTypecast() as 1 and 0 respectively.
  • bareword defaults to their literal text value, matching SQLite’s non-parenthesized DEFAULT word behavior.
  • 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

ParameterTypeDescription
$valuemixedDefault value in SQLite dflt_value format.

Returns

mixed: Converted value.

Since

22.0