Class yii\db\mssql\Schema
Inheritance | yii\db\mssql\Schema » yii\db\Schema » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable, yii\db\ConstraintFinderInterface |
Uses Traits | yii\db\ConstraintFinderTrait, yii\db\ViewFinderTrait |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/db/mssql/Schema.php |
Schema is the class for retrieving metadata from MS SQL Server databases (version 2008 and above).
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$columnSchemaClass | string|array | Column schema class or class config | 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\mssql\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 |
$lastInsertID | string | The row ID of the last row inserted, or the last value retrieved from the sequence object | yii\db\Schema |
$queryBuilder | yii\db\QueryBuilder | The query builder for this connection. | yii\db\Schema |
$schemaChecks | \yii\db\CheckConstraint[][] | Check constraints for all tables in the database. | yii\db\ConstraintFinderTrait |
$schemaDefaultValues | yii\db\DefaultValueConstraint[] | Default value constraints for all tables in the database. | yii\db\ConstraintFinderTrait |
$schemaForeignKeys | \yii\db\ForeignKeyConstraint[][] | Foreign keys for all tables in the database. | yii\db\ConstraintFinderTrait |
$schemaIndexes | \yii\db\IndexConstraint[][] | Indexes for all tables in the database. | yii\db\ConstraintFinderTrait |
$schemaNames | string[] | All schema names in the database, except system schemas. | yii\db\Schema |
$schemaPrimaryKeys | yii\db\Constraint[] | Primary keys for all tables in the database. | yii\db\ConstraintFinderTrait |
$schemaUniques | \yii\db\Constraint[][] | Unique constraints for all tables in the database. | yii\db\ConstraintFinderTrait |
$serverVersion | string | Server version as a string. | yii\db\Schema |
$tableNames | string[] | All table names in the database. | yii\db\Schema |
$tableSchemas | yii\db\TableSchema[] | The metadata for all tables in the database. | yii\db\Schema |
$transactionIsolationLevel | string | The transaction isolation level to use for this transaction. | yii\db\Schema |
$typeMap | array | Mapping from physical column types (keys) to abstract column types (values) | yii\db\mssql\Schema |
$viewNames | string[] | All view names in the database. | yii\db\ViewFinderTrait |
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$columnQuoteCharacter | {@inheritdoc} | yii\db\mssql\Schema | |
$tableQuoteCharacter | {@inheritdoc} | yii\db\mssql\Schema |
Public Methods
Method | Description | Defined 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 MSSQL database. | yii\db\mssql\Schema |
createSavepoint() | {@inheritdoc} | yii\db\mssql\Schema |
findUniqueIndexes() | Returns all unique indexes for the given table. | yii\db\mssql\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 |
getServerVersion() | Returns a server version as a string comparable by \version_compare(). | yii\db\Schema |
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\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 simple table name for use in a query. | yii\db\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() | {@inheritdoc} | yii\db\mssql\Schema |
rollBackSavepoint() | {@inheritdoc} | yii\db\mssql\Schema |
setTransactionIsolationLevel() | Sets the isolation level of the current transaction. | yii\db\Schema |
supportsSavepoint() | yii\db\Schema | |
unquoteSimpleColumnName() | Unquotes a simple column name. | yii\db\Schema |
unquoteSimpleTableName() | Unquotes a simple table name. | yii\db\Schema |
Protected Methods
Method | Description | Defined By |
---|---|---|
createColumnSchema() | Creates a column schema for the database. | yii\db\Schema |
findColumns() | Collects the metadata of table columns. | yii\db\mssql\Schema |
findForeignKeys() | Collects the foreign key column details for the given table. | yii\db\mssql\Schema |
findPrimaryKeys() | Collects the primary key column details for the given table. | yii\db\mssql\Schema |
findSchemaNames() | {@inheritdoc} | yii\db\mssql\Schema |
findTableConstraints() | Collects the constraint details for the given table and constraint type. | yii\db\mssql\Schema |
findTableNames() | {@inheritdoc} | yii\db\mssql\Schema |
findViewNames() | {@inheritdoc} | yii\db\mssql\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 |
loadColumnSchema() | Loads the column information into a yii\db\ColumnSchema object. | yii\db\mssql\Schema |
loadTableChecks() | {@inheritdoc} | yii\db\mssql\Schema |
loadTableDefaultValues() | {@inheritdoc} | yii\db\mssql\Schema |
loadTableForeignKeys() | {@inheritdoc} | yii\db\mssql\Schema |
loadTableIndexes() | {@inheritdoc} | yii\db\mssql\Schema |
loadTablePrimaryKey() | {@inheritdoc} | yii\db\mssql\Schema |
loadTableSchema() | {@inheritdoc} | yii\db\mssql\Schema |
loadTableUniques() | {@inheritdoc} | yii\db\mssql\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\mssql\Schema |
resolveTableNames() | Resolves the table name and schema name (if any). | yii\db\mssql\Schema |
setTableMetadata() | Sets the metadata of the given type for the given table. | yii\db\Schema |
Constants
Constant | Value | Description | Defined 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_JSON | 'json' | 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_TINYINT | 'tinyint' | yii\db\Schema | |
TYPE_UBIGPK | 'ubigpk' | yii\db\Schema | |
TYPE_UPK | 'upk' | yii\db\Schema |
Property Details
The default schema used for the current session.
Mapping from physical column types (keys) to abstract column types (values)
Method Details
Creates a query builder for the MSSQL database.
public yii\db\mssql\QueryBuilder createQueryBuilder ( ) | ||
return | yii\db\mssql\QueryBuilder | Query builder interface. |
---|
{@inheritdoc}
public void createSavepoint ( $name ) | ||
$name |
Collects the metadata of table columns.
protected boolean findColumns ( $table ) | ||
$table | yii\db\mssql\TableSchema | The table metadata |
return | boolean | Whether the table exists in the database |
---|
Collects the foreign key column details for the given table.
protected void findForeignKeys ( $table ) | ||
$table | yii\db\mssql\TableSchema | The table metadata |
Collects the primary key column details for the given table.
protected void findPrimaryKeys ( $table ) | ||
$table | yii\db\mssql\TableSchema | The table metadata |
{@inheritdoc}
protected void findSchemaNames ( ) |
Collects the constraint details for the given table and constraint type.
protected array findTableConstraints ( $table, $type ) | ||
$table | yii\db\mssql\TableSchema | |
$type | string | Either PRIMARY KEY or UNIQUE |
return | array | Each entry contains index_name and field_name |
---|
{@inheritdoc}
protected void findTableNames ( $schema = '' ) | ||
$schema |
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\mssql\TableSchema | The table metadata |
return | array | All unique indexes for the given table. |
---|
{@inheritdoc}
protected void findViewNames ( $schema = '' ) | ||
$schema |
Loads the column information into a yii\db\ColumnSchema object.
protected yii\db\ColumnSchema loadColumnSchema ( $info ) | ||
$info | array | Column information |
return | yii\db\ColumnSchema | The column schema object |
---|
{@inheritdoc}
protected void loadTableChecks ( $tableName ) | ||
$tableName |
{@inheritdoc}
protected void loadTableDefaultValues ( $tableName ) | ||
$tableName |
{@inheritdoc}
protected void loadTableForeignKeys ( $tableName ) | ||
$tableName |
{@inheritdoc}
protected void loadTableIndexes ( $tableName ) | ||
$tableName |
{@inheritdoc}
protected void loadTablePrimaryKey ( $tableName ) | ||
$tableName |
{@inheritdoc}
protected void loadTableSchema ( $name ) | ||
$name |
{@inheritdoc}
protected void loadTableUniques ( $tableName ) | ||
$tableName |
{@inheritdoc}
public void releaseSavepoint ( $name ) | ||
$name |
Resolves the table name and schema name (if any).
protected yii\db\mssql\TableSchema resolveTableName ( $name ) | ||
$name | string | The table name |
return | yii\db\mssql\TableSchema | Resolved table, schema, etc. names. |
---|
Resolves the table name and schema name (if any).
protected void resolveTableNames ( $table, $name ) | ||
$table | yii\db\mssql\TableSchema | The table metadata object |
$name | string | The table name |
{@inheritdoc}
public void rollBackSavepoint ( $name ) | ||
$name |
Signup or Login in order to comment.