# ColumnSchema

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

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [db](/docs/api/yii/db/index.md) › [sqlite](/docs/api/yii/db/sqlite/index.md) › ColumnSchema

| class | `yii\db\sqlite\ColumnSchema` |
| --- | --- |
| Extends | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Since | 22.0 |
| Source | [`framework/db/sqlite/ColumnSchema.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/db/sqlite/ColumnSchema.php#L28) |

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

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-allowNull"></span>[`$allowNull`](/docs/api/yii/db/columnschema/index.md#property-allowNull) | `bool` | Whether this column can be null. Default: `false`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-autoIncrement"></span>[`$autoIncrement`](/docs/api/yii/db/columnschema/index.md#property-autoIncrement) | `bool` | Whether this column is auto-incremental Default: `false`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-comment"></span>[`$comment`](/docs/api/yii/db/columnschema/index.md#property-comment) | `string\|null` | Comment of this column. Default: `null`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-dbType"></span>[`$dbType`](/docs/api/yii/db/columnschema/index.md#property-dbType) | `string` | The DB type of this column. Default: `''`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-defaultValue"></span>[`$defaultValue`](/docs/api/yii/db/columnschema/index.md#property-defaultValue) | `mixed` | Default value of this column Default: `null`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-enumValues"></span>[`$enumValues`](/docs/api/yii/db/columnschema/index.md#property-enumValues) | `array\|null` | Enumerable values. Default: `null`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-isPrimaryKey"></span>[`$isPrimaryKey`](/docs/api/yii/db/columnschema/index.md#property-isPrimaryKey) | `bool\|null` | Whether this column is a primary key Default: `null`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-name"></span>[`$name`](/docs/api/yii/db/columnschema/index.md#property-name) | `string` | Name of this column (without quotes). Default: `''`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-phpType"></span>[`$phpType`](/docs/api/yii/db/columnschema/index.md#property-phpType) | `string` | The PHP type of this column. Default: `''`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-precision"></span>[`$precision`](/docs/api/yii/db/columnschema/index.md#property-precision) | `int\|null` | Precision of the column data, if it is numeric. Default: `null`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-scale"></span>[`$scale`](/docs/api/yii/db/columnschema/index.md#property-scale) | `int\|null` | Scale of the column data, if it is numeric. Default: `null`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-size"></span>[`$size`](/docs/api/yii/db/columnschema/index.md#property-size) | `int\|null` | Display size of the column. Default: `null`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-type"></span>[`$type`](/docs/api/yii/db/columnschema/index.md#property-type) | `string` | Abstract type of this column. Default: `''`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="property-unsigned"></span>[`$unsigned`](/docs/api/yii/db/columnschema/index.md#property-unsigned) | `bool` | Whether this column is unsigned. Default: `false`. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/baseobject/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/baseobject/index.md#method-__get) | Returns the value of an object property. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/baseobject/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/baseobject/index.md#method-__set) | Sets value of an object property. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/baseobject/index.md#method-__unset) | Sets an object property to null. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/baseobject/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/baseobject/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-dbTypecast"></span>[`dbTypecast()`](/docs/api/yii/db/columnschema/index.md#method-dbTypecast) | Converts the input value according to [`$type`](/docs/api/yii/db/columnschema/index.md#property-type) and [`$dbType`](/docs/api/yii/db/columnschema/index.md#property-dbType) for use in a db query. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| [`defaultPhpTypecast()`](#method-defaultPhpTypecast) | Converts a SQLite column default value to its PHP representation. | `ColumnSchema` |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/baseobject/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/baseobject/index.md#method-hasProperty) | Returns a value indicating whether a property is defined. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-init"></span>[`init()`](/docs/api/yii/base/baseobject/index.md#method-init) | Initializes the object. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-isType"></span>[`isType()`](/docs/api/yii/db/columnschema/index.md#method-isType) | Returns whether this column uses the given abstract type. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="method-phpTypecast"></span>[`phpTypecast()`](/docs/api/yii/db/columnschema/index.md#method-phpTypecast) | Converts the input value according to [`$phpType`](/docs/api/yii/db/columnschema/index.md#property-phpType) after retrieval from the database. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |
| <span id="method-typecast"></span>[`typecast()`](/docs/api/yii/db/columnschema/index.md#method-typecast) protected | Converts the input value according to [`$phpType`](/docs/api/yii/db/columnschema/index.md#property-phpType) after retrieval from the database. | [`yii\db\ColumnSchema`](/docs/api/yii/db/columnschema/index.md) |

## Method details

### defaultPhpTypecast() <span id="method-defaultPhpTypecast"></span>

```php
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`](/docs/api/yii/db/expression/index.md).
- single, double, backtick, or bracket-quoted string literals to their unquoted PHP value.
- signed decimal and scientific numeric literals through [`ColumnSchema::phpTypecast()`](/docs/api/yii/db/columnschema/index.md#method-phpTypecast).
- `TRUE` and `FALSE` through [`ColumnSchema::phpTypecast()`](/docs/api/yii/db/columnschema/index.md#method-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`](/docs/api/yii/db/expression/index.md), 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