Class yii\db\pgsql\Schema

Inheritanceyii\db\pgsql\Schema » yii\db\Schema » yii\base\BaseObject
Implementsyii\base\Configurable
Uses Traitsyii\db\ConstraintFinderTrait, yii\db\ViewFinderTrait
Available since version2.0
Source Code https://github.com/yiisoft/yii2/blob/master/framework/db/pgsql/Schema.php

Schema is the class for retrieving metadata from a PostgreSQL database (version 9.x and above).

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$columnSchemaClass string Column schema class yii\db\Schema
$db yii\db\Connection The database connection yii\db\Schema
$defaultSchema string The default schema used for the current session. yii\db\pgsql\Schema
$exceptionMap array Map of DB errors and corresponding exceptions If left part is found in DB error message exception class from the right part is used. yii\db\Schema
$typeMap array Mapping from physical column types (keys) to abstract column types (values) yii\db\pgsql\Schema

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\BaseObject
__construct() Constructor. 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() Returns the fully qualified name of this class. yii\base\BaseObject
convertException() Converts a DB exception to a more concrete one if possible. yii\db\Schema
createColumnSchemaBuilder() Create a column schema builder instance giving the type and value precision. yii\db\Schema
createQueryBuilder() Creates a query builder for the PostgreSQL database. yii\db\pgsql\Schema
createSavepoint() Creates a new savepoint. yii\db\Schema
findUniqueIndexes() Returns all unique indexes for the given table. yii\db\pgsql\Schema
getLastInsertID() Returns the ID of the last inserted row or sequence value. yii\db\Schema
getPdoType() Determines the PDO type for the given PHP data value. yii\db\Schema
getQueryBuilder() yii\db\Schema
getRawTableName() Returns the actual name of a given table name. yii\db\Schema
getSchemaChecks() Returns check constraints for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaDefaultValues() Returns default value constraints for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaForeignKeys() Returns foreign keys for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaIndexes() Returns indexes for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaNames() Returns all schema names in the database, except system schemas. yii\db\Schema
getSchemaPrimaryKeys() Returns primary keys for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaUniques() Returns unique constraints for all tables in the database. yii\db\ConstraintFinderTrait
getTableChecks() Obtains the check constraints information for the named table. yii\db\ConstraintFinderTrait
getTableDefaultValues() Obtains the default value constraints information for the named table. yii\db\ConstraintFinderTrait
getTableForeignKeys() Obtains the foreign keys information for the named table. yii\db\ConstraintFinderTrait
getTableIndexes() Obtains the indexes information for the named table. yii\db\ConstraintFinderTrait
getTableNames() Returns all table names in the database. yii\db\Schema
getTablePrimaryKey() Obtains the primary key for the named table. yii\db\ConstraintFinderTrait
getTableSchema() Obtains the metadata for the named table. yii\db\Schema
getTableSchemas() Returns the metadata for all tables in the database. yii\db\Schema
getTableUniques() Obtains the unique constraints information for the named table. yii\db\ConstraintFinderTrait
getViewNames() Returns all view names in the database. yii\db\ViewFinderTrait
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
insert() Executes the INSERT command, returning primary key values. yii\db\pgsql\Schema
isReadQuery() Returns a value indicating whether a SQL statement is for read purpose. yii\db\Schema
quoteColumnName() Quotes a column name for use in a query. yii\db\Schema
quoteSimpleColumnName() Quotes a simple column name for use in a query. yii\db\Schema
quoteSimpleTableName() Quotes a table name for use in a query. yii\db\pgsql\Schema
quoteTableName() Quotes a table name for use in a query. yii\db\Schema
quoteValue() Quotes a string value for use in a query. yii\db\Schema
refresh() Refreshes the schema. yii\db\Schema
refreshTableSchema() Refreshes the particular table schema. yii\db\Schema
releaseSavepoint() Releases an existing savepoint. yii\db\Schema
rollBackSavepoint() Rolls back to a previously created savepoint. yii\db\Schema
setTransactionIsolationLevel() Sets the isolation level of the current transaction. yii\db\Schema
supportsSavepoint() yii\db\Schema

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
createColumnSchema() Creates a column schema for the database. yii\db\Schema
findColumns() Collects the metadata of table columns. yii\db\pgsql\Schema
findConstraints() Collects the foreign key column details for the given table. yii\db\pgsql\Schema
findSchemaNames() Returns all schema names in the database, including the default one but not system schemas. yii\db\pgsql\Schema
findTableNames() Returns all table names in the database. yii\db\pgsql\Schema
findViewNames() yii\db\pgsql\Schema
getCacheKey() Returns the cache key for the specified table name. yii\db\Schema
getCacheTag() Returns the cache tag name. yii\db\Schema
getColumnPhpType() Extracts the PHP type from abstract DB type. yii\db\Schema
getSchemaMetadata() Returns the metadata of the given type for all tables in the given schema. yii\db\ConstraintFinderTrait
getTableMetadata() Returns the metadata of the given type for the given table. yii\db\ConstraintFinderTrait
getUniqueIndexInformation() Gets information about given table unique indexes. yii\db\pgsql\Schema
loadColumnSchema() Loads the column information into a \yii\db\pgsql\ColumnSchema object. yii\db\pgsql\Schema
loadTableChecks() yii\db\pgsql\Schema
loadTableDefaultValues() yii\db\pgsql\Schema
loadTableForeignKeys() yii\db\pgsql\Schema
loadTableIndexes() yii\db\pgsql\Schema
loadTablePrimaryKey() yii\db\pgsql\Schema
loadTableSchema() Loads the metadata for the specified table. yii\db\pgsql\Schema
loadTableUniques() yii\db\pgsql\Schema
normalizePdoRowKeyCase() Changes row's array key case to lower if PDO's one is set to uppercase. yii\db\Schema
resolveTableName() Resolves the table name and schema name (if any). yii\db\pgsql\Schema
resolveTableNames() Resolves the table name and schema name (if any). yii\db\pgsql\Schema
setTableMetadata() Sets the metadata of the given type for the given table. yii\db\Schema

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
SCHEMA_CACHE_VERSION 1 Schema cache version, to detect incompatibilities in cached values when the data format of the cache changes. yii\db\Schema
TYPE_BIGINT 'bigint' yii\db\Schema
TYPE_BIGPK 'bigpk' yii\db\Schema
TYPE_BINARY 'binary' yii\db\Schema
TYPE_BOOLEAN 'boolean' yii\db\Schema
TYPE_CHAR 'char' yii\db\Schema
TYPE_DATE 'date' yii\db\Schema
TYPE_DATETIME 'datetime' yii\db\Schema
TYPE_DECIMAL 'decimal' yii\db\Schema
TYPE_DOUBLE 'double' yii\db\Schema
TYPE_FLOAT 'float' yii\db\Schema
TYPE_INTEGER 'integer' yii\db\Schema
TYPE_MONEY 'money' yii\db\Schema
TYPE_PK 'pk' yii\db\Schema
TYPE_SMALLINT 'smallint' yii\db\Schema
TYPE_STRING 'string' yii\db\Schema
TYPE_TEXT 'text' yii\db\Schema
TYPE_TIME 'time' yii\db\Schema
TYPE_TIMESTAMP 'timestamp' yii\db\Schema
TYPE_UBIGPK 'ubigpk' yii\db\Schema
TYPE_UPK 'upk' yii\db\Schema

Property Details

$defaultSchema public property

The default schema used for the current session.

public string $defaultSchema 'public'
$typeMap public property

Mapping from physical column types (keys) to abstract column types (values)

See also http://www.postgresql.org/docs/current/static/datatype.html#DATATYPE-TABLE.

public array $typeMap = ['bit' => self::TYPE_INTEGER'bit varying' => self::TYPE_INTEGER'varbit' => self::TYPE_INTEGER'bool' => self::TYPE_BOOLEAN'boolean' => self::TYPE_BOOLEAN'box' => self::TYPE_STRING'circle' => self::TYPE_STRING'point' => self::TYPE_STRING'line' => self::TYPE_STRING'lseg' => self::TYPE_STRING'polygon' => self::TYPE_STRING'path' => self::TYPE_STRING'character' => self::TYPE_CHAR'char' => self::TYPE_CHAR'bpchar' => self::TYPE_CHAR'character varying' => self::TYPE_STRING'varchar' => self::TYPE_STRING'text' => self::TYPE_TEXT'bytea' => self::TYPE_BINARY'cidr' => self::TYPE_STRING'inet' => self::TYPE_STRING'macaddr' => self::TYPE_STRING'real' => self::TYPE_FLOAT'float4' => self::TYPE_FLOAT'double precision' => self::TYPE_DOUBLE'float8' => self::TYPE_DOUBLE'decimal' => self::TYPE_DECIMAL'numeric' => self::TYPE_DECIMAL'money' => self::TYPE_MONEY'smallint' => self::TYPE_SMALLINT'int2' => self::TYPE_SMALLINT'int4' => self::TYPE_INTEGER'int' => self::TYPE_INTEGER'integer' => self::TYPE_INTEGER'bigint' => self::TYPE_BIGINT'int8' => self::TYPE_BIGINT'oid' => self::TYPE_BIGINT'smallserial' => self::TYPE_SMALLINT'serial2' => self::TYPE_SMALLINT'serial4' => self::TYPE_INTEGER'serial' => self::TYPE_INTEGER'bigserial' => self::TYPE_BIGINT'serial8' => self::TYPE_BIGINT'pg_lsn' => self::TYPE_BIGINT'date' => self::TYPE_DATE'interval' => self::TYPE_STRING'time without time zone' => self::TYPE_TIME'time' => self::TYPE_TIME'time with time zone' => self::TYPE_TIME'timetz' => self::TYPE_TIME'timestamp without time zone' => self::TYPE_TIMESTAMP'timestamp' => self::TYPE_TIMESTAMP'timestamp with time zone' => self::TYPE_TIMESTAMP'timestamptz' => self::TYPE_TIMESTAMP'abstime' => self::TYPE_TIMESTAMP'tsquery' => self::TYPE_STRING'tsvector' => self::TYPE_STRING'txid_snapshot' => self::TYPE_STRING'unknown' => self::TYPE_STRING'uuid' => self::TYPE_STRING'json' => self::TYPE_STRING'jsonb' => self::TYPE_STRING'xml' => self::TYPE_STRING]

Method Details

createQueryBuilder() public method

Creates a query builder for the PostgreSQL database.

public yii\db\pgsql\QueryBuilder createQueryBuilder ( )
return yii\db\pgsql\QueryBuilder

Query builder instance

findColumns() protected method

Collects the metadata of table columns.

protected boolean findColumns ( $table )
$table yii\db\TableSchema

The table metadata

return boolean

Whether the table exists in the database

findConstraints() protected method

Collects the foreign key column details for the given table.

protected void findConstraints ( $table )
$table yii\db\TableSchema

The table metadata

findSchemaNames() protected method

Returns all schema names in the database, including the default one but not system schemas.

This method should be overridden by child classes in order to support this feature because the default implementation simply throws an exception.

protected array findSchemaNames ( )
return array

All schema names in the database, except system schemas.

throws yii\base\NotSupportedException

if this method is not supported by the DBMS.

findTableNames() protected method

Returns all table names in the database.

This method should be overridden by child classes in order to support this feature because the default implementation simply throws an exception.

protected array findTableNames ( $schema '' )
$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema.

return array

All table names in the database. The names have NO schema name prefix.

throws yii\base\NotSupportedException

if this method is not supported by the DBMS.

findUniqueIndexes() public method

Returns all unique indexes for the given table.

Each array element is of the following structure:

[
    'IndexName1' => ['col1' [, ...]],
    'IndexName2' => ['col2' [, ...]],
]
public array findUniqueIndexes ( $table )
$table yii\db\TableSchema

The table metadata

return array

All unique indexes for the given table.

findViewNames() protected method

protected void findViewNames ( $schema '' )
$schema
getUniqueIndexInformation() protected method

Gets information about given table unique indexes.

protected array getUniqueIndexInformation ( $table )
$table yii\db\TableSchema

The table metadata

return array

With index and column names

insert() public method

Executes the INSERT command, returning primary key values.

public array|false insert ( $table, $columns )
$table string

The table that new rows will be inserted into.

$columns array

The column data (name => value) to be inserted into the table.

return array|false

Primary key values or false if the command fails

loadColumnSchema() protected method

Loads the column information into a \yii\db\pgsql\ColumnSchema object.

protected \yii\db\pgsql\ColumnSchema loadColumnSchema ( $info )
$info array

Column information

return \yii\db\pgsql\ColumnSchema

The column schema object

loadTableChecks() protected method

protected void loadTableChecks ( $tableName )
$tableName
loadTableDefaultValues() protected method

protected void loadTableDefaultValues ( $tableName )
$tableName
throws yii\base\NotSupportedException

if this method is called.

loadTableForeignKeys() protected method

protected void loadTableForeignKeys ( $tableName )
$tableName
loadTableIndexes() protected method

protected void loadTableIndexes ( $tableName )
$tableName
loadTablePrimaryKey() protected method

protected void loadTablePrimaryKey ( $tableName )
$tableName
loadTableSchema() protected method

Loads the metadata for the specified table.

protected yii\db\TableSchema|null loadTableSchema ( $name )
$name string

Table name

return yii\db\TableSchema|null

DBMS-dependent table metadata, null if the table does not exist.

loadTableUniques() protected method

protected void loadTableUniques ( $tableName )
$tableName
quoteSimpleTableName() public method

Quotes a table name for use in a query.

A simple table name has no schema prefix.

public string quoteSimpleTableName ( $name )
$name string

Table name

return string

The properly quoted table name

resolveTableName() protected method

Resolves the table name and schema name (if any).

protected yii\db\TableSchema resolveTableName ( $name )
$name string

The table name

return yii\db\TableSchema

yii\db\TableSchema with resolved table, schema, etc. names.

throws yii\base\NotSupportedException

if this method is not supported by the DBMS.

resolveTableNames() protected method

Resolves the table name and schema name (if any).

protected void resolveTableNames ( $table, $name )
$table yii\db\TableSchema

The table metadata object

$name string

The table name