W3cubDocs

/Yii 2.0

Class yii\db\mssql\Schema

Inheritance yii\db\mssql\Schema » yii\db\Schema » yii\base\Object
Implements yii\base\Configurable
Uses Traits 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 a MS SQL Server databases (version 2008 and above).

Public Properties

Property Type Description Defined 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\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
$schemaNames string[] All schema names in the database, except system schemas. 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

Public Methods

Method Description Defined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Returns the value of an object property. yii\base\Object
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Sets value of an object property. yii\base\Object
__unset() Sets an object property to null. yii\base\Object
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Object
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Object
className() Returns the fully qualified name of this class. yii\base\Object
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() Creates a new savepoint. 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
getSchemaNames() Returns all schema names in the database, except system schemas. yii\db\Schema
getTableNames() Returns all table names in the database. yii\db\Schema
getTableSchema() Obtains the metadata for the named table. yii\db\Schema
getTableSchemas() Returns the metadata for all tables in the database. yii\db\Schema
getViewNames() Returns all view names in the database. yii\db\ViewFinderTrait
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. yii\base\Object
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
loadTableSchema() Loads the metadata for the specified table. yii\db\mssql\Schema
quoteColumnName() Quotes a column name for use in a query. yii\db\Schema
quoteSimpleColumnName() Quotes a column name for use in a query. yii\db\mssql\Schema
quoteSimpleTableName() Quotes a table name for use in a query. yii\db\mssql\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\mssql\Schema
rollBackSavepoint() Rolls back to a previously created savepoint. yii\db\mssql\Schema
setTransactionIsolationLevel() Sets the isolation level of the current transaction. yii\db\Schema
supportsSavepoint() yii\db\Schema

Protected Methods

Method Description Defined By
createColumnSchema() 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() Returns all schema names in the database, including the default one but not system schemas. yii\db\Schema
findTableConstraints() Collects the constraint details for the given table and constraint type. yii\db\mssql\Schema
findTableNames() Returns all table names in the database. yii\db\mssql\Schema
findViewNames() 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
loadColumnSchema() Loads the column information into a yii\db\ColumnSchema object. yii\db\mssql\Schema
resolveTableNames() Resolves the table name and schema name (if any). yii\db\mssql\Schema

Constants

Constant Value Description Defined By
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 = 'dbo'

$typeMap public property

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

public array $typeMap = ['bigint' => self::TYPE_BIGINT, 'numeric' => self::TYPE_DECIMAL, 'bit' => self::TYPE_SMALLINT, 'smallint' => self::TYPE_SMALLINT, 'decimal' => self::TYPE_DECIMAL, 'smallmoney' => self::TYPE_MONEY, 'int' => self::TYPE_INTEGER, 'tinyint' => self::TYPE_SMALLINT, 'money' => self::TYPE_MONEY, 'float' => self::TYPE_FLOAT, 'double' => self::TYPE_DOUBLE, 'real' => self::TYPE_FLOAT, 'date' => self::TYPE_DATE, 'datetimeoffset' => self::TYPE_DATETIME, 'datetime2' => self::TYPE_DATETIME, 'smalldatetime' => self::TYPE_DATETIME, 'datetime' => self::TYPE_DATETIME, 'time' => self::TYPE_TIME, 'char' => self::TYPE_CHAR, 'varchar' => self::TYPE_STRING, 'text' => self::TYPE_TEXT, 'nchar' => self::TYPE_CHAR, 'nvarchar' => self::TYPE_STRING, 'ntext' => self::TYPE_TEXT, 'binary' => self::TYPE_BINARY, 'varbinary' => self::TYPE_BINARY, 'image' => self::TYPE_BINARY, 'timestamp' => self::TYPE_TIMESTAMP, 'hierarchyid' => self::TYPE_STRING, 'uniqueidentifier' => self::TYPE_STRING, 'sql_variant' => self::TYPE_STRING, 'xml' => self::TYPE_STRING, 'table' => self::TYPE_STRING]

Method Details

createQueryBuilder() public method

Creates a query builder for the MSSQL database.

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

Query builder interface.

createSavepoint() public method

Creates a new savepoint.

public void createSavepoint ( $name )
$name string

The savepoint name

findColumns() protected method

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

findForeignKeys() protected method

Collects the foreign key column details for the given table.

protected void findForeignKeys ( $table )
$table yii\db\mssql\TableSchema

The table metadata

findPrimaryKeys() protected method

Collects the primary key column details for the given table.

protected void findPrimaryKeys ( $table )
$table yii\db\mssql\TableSchema

The table metadata

findTableConstraints() protected method (available since version 2.0.4)

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

findTableNames() protected method

Returns all table names in the database.

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.

findUniqueIndexes() public method (available since version 2.0.4)

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.

findViewNames() protected method

protected void findViewNames ( $schema = '' )
$schema

loadColumnSchema() protected method

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

loadTableSchema() public method

Loads the metadata for the specified table.

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

Table name

return yii\db\mssql\TableSchema|null

Driver dependent table metadata. Null if the table does not exist.

quoteSimpleColumnName() public method

Quotes a column name for use in a query.

A simple column name has no prefix.

public string quoteSimpleColumnName ( $name )
$name string

Column name.

return string

The properly quoted column name.

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.

releaseSavepoint() public method

Releases an existing savepoint.

public void releaseSavepoint ( $name )
$name string

The savepoint name

resolveTableNames() protected method

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

rollBackSavepoint() public method

Rolls back to a previously created savepoint.

public void rollBackSavepoint ( $name )
$name string

The savepoint name

© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-db-mssql-schema.html