Skip to content
PHP Ecosystem
Explore

ColumnSchema

API reference › yii › db › pgsql › ColumnSchema

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

Represents the metadata of a column in a PostgreSQL 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
$dimensionintThe dimension of array. Default: 0.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
$sequenceNamestring|nullName of associated sequence if column is auto-incremental. null if no sequence. Default: null. Available since 2.0.29.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.ColumnSchema
defaultPhpTypecast()Converts a PostgreSQL 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.ColumnSchema
getArrayParser() protectedCreates instance of ArrayParserColumnSchema
phpTypecastValue() protectedCasts $value after retrieving from the DBMS to PHP representation.ColumnSchema
typecast() protectedConverts the input value according to $phpType after retrieval from the database.yii\db\ColumnSchema
public int $dimension = 0

The dimension of array.

Defaults to 0, means this column is not an array.

public function dbTypecast(mixed $value): mixed

Converts 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

ParameterTypeDescription
$valuemixedInput 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.

public function defaultPhpTypecast(mixed $value): mixed

Converts a PostgreSQL column default value to its PHP representation.

Recognizes the literal formats produced by pg_get_expr() and typecasts only those:

  • NULL or (NULL), optionally followed by a direct type cast, to null.
  • Binary bit literals (B'...'::) to their integer value via bindec(); kept for backward compatibility, pg_get_expr() reports bit defaults in the quoted form.
  • Quoted bit literals ('...'::"bit") to their integer value via bindec(); bit varying defaults carry the same "bit" cast label.
  • Quoted literals with a cast ('value'::type, including type modifiers such as character varying(10)) to the unquoted value with doubled quotes unescaped, delegated to phpTypecast().
  • Numeric literals, optionally parenthesized and optionally cast (42, 1.5, (0)::numeric), delegated to phpTypecast().
  • Bare true/false to 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

ParameterTypeDescription
$valuemixedRaw default value in PostgreSQL schema metadata format.

Returns

mixed: Converted PHP value.

Since

22.0

public function phpTypecast(mixed $value): mixed

Converts 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

ParameterTypeDescription
$valuemixedInput value

Returns

mixed: Converted value

protected function getArrayParser(): yii\db\pgsql\ArrayParser

Creates instance of ArrayParser

Returns

ArrayParser

protected function phpTypecastValue(string|null $value): bool|mixed|null

Casts $value after retrieving from the DBMS to PHP representation.

Parameters

ParameterTypeDescription
$valuestring|null

Returns

bool|mixed|null