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.0
Public Properties ​
| Property | Description |
|---|---|
| backupFormat | string, null |
| columnSchemaClass | string, array – Column schema class or class config |
| db | craft\db\Connection |
| defaultBackupCommand | string – The command to execute |
| defaultRestoreCommand | string – The command to execute |
| defaultSchema | string – The default schema used for the current session. |
| 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. |
| lastInsertID | string – The row ID of the last row inserted, or the last value retrieved from the sequence object. |
| maxObjectNameLength | integer – The maximum length that objects' names can be. |
| queryBuilder | yii\db\QueryBuilder – The query builder for this connection. |
| restoreFormat | string, null |
| schemaChecks | \yii\db\CheckConstraint[][] – Check constraints for all tables in the database. |
| schemaDefaultValues | yii\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. |
| schemaNames | string[] – All schema names in the database, except system schemas. |
| schemaPrimaryKeys | yii\db\Constraint – Primary keys for all tables in the database. |
| schemaUniques | \yii\db\IndexConstraint[][] – Unique constraints for all tables in the database. |
| serverVersion | string – Server version as a string. |
| tableNames | string[] – All table names in the database. |
| tableSchemas | yii\db\TableSchema – The metadata for all tables in the database. |
| transactionIsolationLevel | string – The transaction isolation level to use for this transaction. |
| typeMap | array – Mapping from physical column types (keys) to abstract column types (values) |
| viewNames | string[] – All view names in the database. |
backupFormat ​
db ​
- Type
- craft\db\Connection
- Default value
null
defaultBackupCommand ​
- Type
- string
- Default value
null- Access
- Read-only
The command to execute
defaultRestoreCommand ​
- Type
- string
- Default value
null- Access
- Read-only
The command to execute
maxObjectNameLength ​
- Type
- integer
- Default value
63
The maximum length that objects' names can be.
restoreFormat ​
Protected Properties ​
| Property | Description |
|---|---|
| columnQuoteCharacter | string, string[] – Character used to quote column names. |
| tableQuoteCharacter | string, string[] – Character used to quote schema, table, etc. |
Public Methods ​
| Method | Description |
|---|---|
| __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. |
| getBackupFormat() | Returns the backup format that should be used (custom, directory, tar, or plain). |
| 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. |
| getRestoreFormat() | Returns the restore format that should be used (custom, directory, tar, or plain). |
| 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 schema information 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. |
| setBackupFormat() | Sets the backup format that should be used (custom, directory, tar, or plain). |
| setRestoreFormat() | Sets the restore format that should be used (custom, directory, tar, or plain). |
| setTransactionIsolationLevel() | Sets the isolation level of the current transaction. |
| supportsMb4() | Returns whether a table supports 4-byte characters. |
| supportsSavepoint() | |
| unquoteSimpleColumnName() | Unquotes a simple column name. |
| unquoteSimpleTableName() | Unquotes a simple table name. |
| usePgRestore() | Whether pg_restore should be used for the restore command. |
createQueryBuilder() ​
Creates a query builder for the database.
This method may be overridden by child classes to create a DBMS-specific query builder.
Returns ​
craft\db\pgsql\QueryBuilder – Query builder instance
findIndexes() ​
Returns all indexes for the given table. Each array element is of the following structure:
[
'IndexName' => [
'columns' => ['col1' [, ...]],
'unique' => false
],
]Arguments ​
$tableName(string) – The name of the table to get the indexes for.
Returns ​
array – All indexes for the given table.
getBackupFormat() ​
- Since
- 5.2.0
Returns the backup format that should be used (custom, directory, tar, or plain).
Returns ​
getDefaultBackupCommand() ​
Returns the default backup command to execute.
Arguments ​
Returns ​
string – The command to execute
getDefaultRestoreCommand() ​
Returns the default database restore command to execute.
Returns ​
string – The command to execute
getLastInsertID() ​
Returns the ID of the last inserted row or sequence value.
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 ​
- yii\base\InvalidCallException
if the DB connection is not active
getRestoreFormat() ​
- Since
- 5.2.0
Returns the restore format that should be used (custom, directory, tar, or plain).
Returns ​
getTableSchema() ​
Obtains the schema information for the named table.
Arguments ​
$name$refresh
Returns ​
craft\db\TableSchema, null –
loadTableSchema() ​
Loads the metadata for the specified table.
Arguments ​
$name(string) – Table name
Returns ​
craft\db\TableSchema, null – Driver dependent table metadata. Null if the table does not exist.
quoteDatabaseName() ​
DEPRECATED
Deprecated in 5.4.0
Quotes a database name for use in a query.
Arguments ​
$name(string)
Returns ​
releaseSavepoint() ​
Releases an existing savepoint.
Arguments ​
$name(string) – The savepoint name.
Throws ​
rollBackSavepoint() ​
Rolls back to a previously created savepoint.
Arguments ​
$name(string) – The savepoint name.
Throws ​
setBackupFormat() ​
- Since
- 5.2.0
Sets the backup format that should be used (custom, directory, tar, or plain).
Arguments ​
setRestoreFormat() ​
- Since
- 5.2.0
Sets the restore format that should be used (custom, directory, tar, or plain).
Arguments ​
supportsMb4() ​
- Since
- 5.0.0
Returns whether a table supports 4-byte characters.
Arguments ​
$table(string) – The table to check
Returns ​
usePgRestore() ​
- Since
- 5.1.0
Whether pg_restore should be used for the restore command.
Returns ​
Protected Methods ​
| Method | Description |
|---|---|
| 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() | {@inheritdoc] |
| 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. |
| getTableNameParts() | Splits full table name into parts |
| getUniqueIndexInformation() | Gets information about given table unique indexes. |
| loadColumnSchema() | Loads the column information into a yii\db\pgsql\ColumnSchema object. |
| loadTableChecks() | |
| loadTableDefaultValues() | |
| loadTableForeignKeys() | |
| loadTableIndexes() | |
| loadTablePrimaryKey() | |
| loadTableUniques() | |
| 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.
Arguments ​
$table(craft\db\TableSchema) – The table metadata
getIndexInformation() ​
Gets information about given table indexes.
Arguments ​
$table(craft\db\TableSchema) – The table metadata
Returns ​
array – Index and column names
Constants ​
| Constant | Description |
|---|---|
SCHEMA_CACHE_VERSION | Schema 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 |