ColumnSchema
API reference › yii › db › pgsql › ColumnSchema
Represents the metadata of a column in a PostgreSQL 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\ |
$dimension | int | The dimension of array. Default: 0. | ColumnSchema |
$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\ |
$sequenceName | string| | Name of associated sequence if column is auto-incremental. null if no sequence. Default: null. Available since 2.0.29. | ColumnSchema |
$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. | ColumnSchema |
defaultPhpTypecast() | Converts a PostgreSQL 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. | ColumnSchema |
getArrayParser() protected | Creates instance of ArrayParser | ColumnSchema |
phpTypecastValue() protected | Casts $value after retrieving from the DBMS to PHP representation. | ColumnSchema |
typecast() protected | Converts the input value according to $phpType after retrieval from the database. | yii\ |
Property details
Section titled “Property details”$dimension
Section titled “$dimension ”public int $dimension = 0The dimension of array.
Defaults to 0, means this column is not an array.
Method details
Section titled “Method details”dbTypecast()
Section titled “dbTypecast() ”public function dbTypecast(mixed $value): mixedConverts the input value according to $type and $dbType for use in a db query.
If the value is null or an Expression, it will not be converted.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Input value |
Returns
mixed: Converted value. This may also be an array containing the value as the first element and the PDO type as the second element.
defaultPhpTypecast()
Section titled “defaultPhpTypecast() ”public function defaultPhpTypecast(mixed $value): mixedConverts a PostgreSQL column default value to its PHP representation.
Recognizes the literal formats produced by pg_get_expr() and typecasts only those:
NULLor(NULL), optionally followed by a direct type cast, tonull.- Binary bit literals (
B'...'::) to their integer value viabindec(); kept for backward compatibility,pg_get_expr()reports bit defaults in the quoted form. - Quoted bit literals (
'...'::"bit") to their integer value viabindec();bit varyingdefaults carry the same"bit"cast label. - Quoted literals with a cast (
'value'::type, including type modifiers such ascharacter varying(10)) to the unquoted value with doubled quotes unescaped, delegated tophpTypecast(). - Numeric literals, optionally parenthesized and optionally cast (
42,1.5,(0)::numeric), delegated tophpTypecast(). - Bare
true/falseto booleans.
Everything else — operator expressions, function calls, nextval(...), CURRENT_* keywords — becomes an
executable Expression. Branch order is significant: the bit branches must precede the generic
quoted-literal branch, or bit strings would be typecast as plain integers.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Raw default value in PostgreSQL schema metadata format. |
Returns
mixed: Converted PHP value.
Since
22.0
phpTypecast()
Section titled “phpTypecast() ”public function phpTypecast(mixed $value): mixedConverts the input value according to $phpType after retrieval from the database.
If the value is null or an Expression, it will not be converted.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Input value |
Returns
mixed: Converted value
getArrayParser()
Section titled “getArrayParser() ”protected function getArrayParser(): yii\db\pgsql\ArrayParserCreates instance of ArrayParser
Returns
phpTypecastValue()
Section titled “phpTypecastValue() ”protected function phpTypecastValue(string|null $value): bool|mixed|nullCasts $value after retrieving from the DBMS to PHP representation.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string| |
Returns
bool|mixed|null