Schema

Type
Class
Namespace
craft\db\pgsql
Inherits
craft\db\pgsql\Schema » yii\db\pgsql\Schema » yii\db\Schema » yii\base\BaseObject
Implements
yii\base\Configurable, yii\db\ConstraintFinderInterface
Uses traits
yii\db\ConstraintFinderTrait, yii\db\ViewFinderTrait
Since
3.0

View source

Public Properties

PropertyDescription
$columnSchemaClassstring, array – Column schema class or class config
$dbyii\db\Connection – The database connection
$defaultBackupCommandstring, false – The command to execute
$defaultRestoreCommandstring – The command to execute
$defaultSchemastring – The default schema name used for the current session.
$exceptionMaparray – Map of DB errors and corresponding exceptions If left part is found in DB error message exception class from the right part is used.
$lastInsertIDstring – The row ID of the last row inserted, or the last value retrieved from the sequence object
$maxObjectNameLengthinteger – The maximum length that objects' names can be.
$queryBuilderyii\db\QueryBuilder – The query builder for this connection.
$schemaChecks\yii\db\CheckConstraint[][] – Check constraints for all tables in the database.
$schemaDefaultValuesyii\db\DefaultValueConstraint – Default value constraints for all tables in the database.
$schemaForeignKeys\yii\db\ForeignKeyConstraint[][] – Foreign keys for all tables in the database.
$schemaIndexes\yii\db\IndexConstraint[][] – Indexes for all tables in the database.
$schemaNamesstring[] – All schema names in the database, except system schemas.
$schemaPrimaryKeysyii\db\Constraint – Primary keys for all tables in the database.
$schemaUniques\yii\db\Constraint[][] – Unique constraints for all tables in the database.
$serverVersionstring – Server version as a string.
$tableNamesstring[] – All table names in the database.
$tableSchemasyii\db\TableSchema – The metadata for all tables in the database.
$transactionIsolationLevelstring – The transaction isolation level to use for this transaction.
$typeMaparray – Mapping from physical column types (keys) to abstract column types (values)
$viewNamesstring[] – All view names in the database.

$defaultBackupCommand

Type
string, false
Access
Read-only

The command to execute

View source

Signature

public string, false getDefaultBackupCommand ( )

$defaultRestoreCommand

Type
string
Access
Read-only

The command to execute

View source

Signature

public string getDefaultRestoreCommand ( )

$lastInsertID

Type
string
Access
Read-only

The row ID of the last row inserted, or the last value retrieved from the sequence object

View source

Signature

public string getLastInsertID ( $sequenceName = '' )

$maxObjectNameLength

Type
integer

The maximum length that objects' names can be.

View source

Signature

public integer $maxObjectNameLength = 63

Protected Properties

PropertyDescription
$columnQuoteCharacterstring, string[] – Character used to quote column names.
$tableQuoteCharacterstring, string[] – Character used to quote schema, table, etc.

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to null.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
convertException()Converts a DB exception to a more concrete one if possible.
createColumnSchemaBuilder()Create a column schema builder instance giving the type and value precision.
createQueryBuilder()Creates a query builder for the database.
createSavepoint()Creates a new savepoint.
findIndexes()Returns all indexes for the given table. Each array element is of the following structure:
findUniqueIndexes()Returns all unique indexes for the given table.
getDefaultBackupCommand()Returns the default backup command to execute.
getDefaultRestoreCommand()Returns the default database restore command to execute.
getLastInsertID()Returns the ID of the last inserted row or sequence value.
getPdoType()Determines the PDO type for the given PHP data value.
getQueryBuilder()
getRawTableName()Returns the actual name of a given table name.
getSchemaChecks()Returns check constraints for all tables in the database.
getSchemaDefaultValues()Returns default value constraints for all tables in the database.
getSchemaForeignKeys()Returns foreign keys for all tables in the database.
getSchemaIndexes()Returns indexes for all tables in the database.
getSchemaNames()Returns all schema names in the database, except system schemas.
getSchemaPrimaryKeys()Returns primary keys for all tables in the database.
getSchemaUniques()Returns unique constraints for all tables in the database.
getServerVersion()Returns a server version as a string comparable by \version_compare().
getTableChecks()Obtains the check constraints information for the named table.
getTableDefaultValues()Obtains the default value constraints information for the named table.
getTableForeignKeys()Obtains the foreign keys information for the named table.
getTableIndexes()Obtains the indexes information for the named table.
getTableNames()Returns all table names in the database.
getTablePrimaryKey()Obtains the primary key for the named table.
getTableSchema()Obtains the metadata for the named table.
getTableSchemas()Returns the metadata for all tables in the database.
getTableUniques()Obtains the unique constraints information for the named table.
getViewNames()Returns all view names in the database.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.
insert()Executes the INSERT command, returning primary key values.
isReadQuery()Returns a value indicating whether a SQL statement is for read purpose.
loadTableSchema()Loads the metadata for the specified table.
quoteColumnName()Quotes a column name for use in a query.
quoteDatabaseName()Quotes a database name for use in a query.
quoteSimpleColumnName()Quotes a simple column name for use in a query.
quoteSimpleTableName()Quotes a simple table name for use in a query.
quoteTableName()Quotes a table name for use in a query.
quoteValue()Quotes a string value for use in a query.
refresh()Refreshes the schema.
refreshTableSchema()Refreshes the particular table schema.
releaseSavepoint()Releases an existing savepoint.
rollBackSavepoint()Rolls back to a previously created savepoint.
setTransactionIsolationLevel()Sets the isolation level of the current transaction.
supportsSavepoint()
unquoteSimpleColumnName()Unquotes a simple column name.
unquoteSimpleTableName()Unquotes a simple table name.

createQueryBuilder()

Creates a query builder for the database. This method may be overridden by child classes to create a DBMS-specific query builder.

View source

Returns

craft\db\pgsql\QueryBuilder – Query builder instance

Signature

public craft\db\pgsql\QueryBuilder createQueryBuilder ( )

findIndexes()

Returns all indexes for the given table. Each array element is of the following structure:

[
    'IndexName1' => ['col1' [, ...]],
    'IndexName2' => ['col2' [, ...]],
]

View source

Arguments

  • $tableName (string) – The name of the table to get the indexes for.

Returns

array – All indexes for the given table.

Signature

public array findIndexes ( \craft\db\pgsql\string $tableName )

getDefaultBackupCommand()

Returns the default backup command to execute.

View source

Returns

string, false – The command to execute

Signature

public string, false getDefaultBackupCommand ( )

getDefaultRestoreCommand()

Returns the default database restore command to execute.

View source

Returns

string – The command to execute

Signature

public string getDefaultRestoreCommand ( )

getLastInsertID()

Returns the ID of the last inserted row or sequence value.

View source

Arguments

  • $sequenceName (string) – Name of the sequence object (required by some DBMS)

Returns

string – The row ID of the last row inserted, or the last value retrieved from the sequence object

Throws

Signature

public string getLastInsertID ( $sequenceName = '' )

loadTableSchema()

Loads the metadata for the specified table.

View source

Arguments

Returns

craft\db\TableSchema, null – Driver dependent table metadata. Null if the table does not exist.

Signature

public craft\db\TableSchema, null loadTableSchema ( $name )

quoteDatabaseName()

Quotes a database name for use in a query.

View source

Arguments

Returns

string

Signature

public string quoteDatabaseName ( \craft\db\pgsql\string $name )

releaseSavepoint()

Releases an existing savepoint.

View source

Arguments

  • $name (string) – The savepoint name.

Throws

Signature

public void releaseSavepoint ( $name )

rollBackSavepoint()

Rolls back to a previously created savepoint.

View source

Arguments

  • $name (string) – The savepoint name.

Throws

Signature

public void rollBackSavepoint ( $name )

Protected Methods

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

findConstraints()

Collects extra foreign key information details for the given table.

View source

Arguments

Signature

protected void findConstraints ( $table )

getIndexInformation()

Gets information about given table indexes.

View source

Arguments

Returns

array – Index and column names

Signature

protected array getIndexInformation ( craft\db\TableSchema $table )

Constants

ConstantDescription
SCHEMA_CACHE_VERSIONSchema cache version, to detect incompatibilities in cached values when the data format of the cache changes.
TYPE_BIGINT
TYPE_BIGPK
TYPE_BINARY
TYPE_BOOLEAN
TYPE_CHAR
TYPE_DATE
TYPE_DATETIME
TYPE_DECIMAL
TYPE_DOUBLE
TYPE_FLOAT
TYPE_INTEGER
TYPE_JSON
TYPE_JSONB
TYPE_MONEY
TYPE_PK
TYPE_SMALLINT
TYPE_STRING
TYPE_TEXT
TYPE_TIME
TYPE_TIMESTAMP
TYPE_TINYINT
TYPE_UBIGPK
TYPE_UPK