没有命名空间的类 yii yii\base yii\behaviors yii\caching yii\captcha yii\console yii\console\controllers yii\console\widgets yii\data yii\db yii\db\conditions yii\db\cubrid yii\db\cubrid\conditions yii\db\mssql yii\db\mssql\conditions yii\db\mysql yii\db\oci yii\db\oci\conditions yii\db\pgsql yii\db\sqlite yii\db\sqlite\conditions yii\di yii\filters yii\filters\auth yii\grid yii\helpers yii\i18n yii\log yii\mail yii\mutex yii\rbac yii\rest yii\test yii\validators yii\web yii\widgets

Class yii\db\mssql\Schema

继承yii\db\mssql\Schema » yii\db\Schema » yii\base\BaseObject
实现yii\base\Configurable, yii\db\ConstraintFinderInterface
使用 Traitsyii\db\ConstraintFinderTrait, yii\db\ViewFinderTrait
可用版本自2.0
源码 https://github.com/yiichina/yii2/blob/api/framework/db/mssql/Schema.php

Schema 是用于从 MS SQL Server 数据库(2008 及以上版本)检索元数据的类。

公共属性

隐藏继承的属性

属性类型描述被定义在
$columnSchemaClass string|array Column schema class or class config yii\db\Schema
$db yii\db\Connection The database connection yii\db\Schema
$defaultSchema string 用于当前会话默认的数据库结构。 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 从物理列类型(键)映射到抽象列类型(值) yii\db\mssql\Schema
$viewNames string[] 数据库中的所有视图名称。 yii\db\ViewFinderTrait

受保护的属性

隐藏继承的属性

属性类型描述被定义在
$columnQuoteCharacter string|string[] Character used to quote column names. yii\db\mssql\Schema
$tableQuoteCharacter string|string[] Character used to quote schema, table, etc. yii\db\mssql\Schema

公共方法

隐藏继承的方法

方法描述被定义在
__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() 为 MSSQL 数据库创建查询构建器。 yii\db\mssql\Schema
createSavepoint() Creates a new savepoint. yii\db\mssql\Schema
findUniqueIndexes() 返回给定表的所有唯一索引。 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() 返回数据库中的所有视图名称。 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() 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
unquoteSimpleColumnName() Unquotes a simple column name. yii\db\Schema
unquoteSimpleTableName() Unquotes a simple table name. yii\db\Schema

受保护的方法

隐藏继承的方法

方法描述被定义在
createColumnSchema() Creates a column schema for the database. yii\db\Schema
findColumns() 收集表列的元数据。 yii\db\mssql\Schema
findForeignKeys() 收集外键列详细信息。 yii\db\mssql\Schema
findPrimaryKeys() 收集给定表的主键列详细信息。 yii\db\mssql\Schema
findSchemaNames() Returns all schema names in the database, including the default one but not system schemas. yii\db\mssql\Schema
findTableConstraints() 收集给定表和约束类型的约束详细信息。 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
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() 将列信息加载到 yii\db\ColumnSchema 对象中。 yii\db\mssql\Schema
loadTableChecks() yii\db\mssql\Schema
loadTableDefaultValues() yii\db\mssql\Schema
loadTableForeignKeys() yii\db\mssql\Schema
loadTableIndexes() yii\db\mssql\Schema
loadTablePrimaryKey() yii\db\mssql\Schema
loadTableSchema() Loads the metadata for the specified table. yii\db\mssql\Schema
loadTableUniques() 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() 解析表名和数据库结构名称(如果存在的话)。 yii\db\mssql\Schema
resolveTableNames() 解析表名和数据结构名称(如果存在的话)。 yii\db\mssql\Schema
setTableMetadata() Sets the metadata of the given type for the given table. yii\db\Schema

常量

隐藏继承的常量

常量描述被定义在
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

属性详情

$columnQuoteCharacter 受保护 属性

Character used to quote column names. An array of 2 characters can be used in case starting and ending characters are different.

protected string|string[] $columnQuoteCharacter = ['['']']
$defaultSchema 公共 属性

用于当前会话默认的数据库结构。

public string $defaultSchema 'dbo'
$tableQuoteCharacter 受保护 属性

Character used to quote schema, table, etc. names. An array of 2 characters can be used in case starting and ending characters are different.

protected string|string[] $tableQuoteCharacter = ['['']']
$typeMap 公共 属性

从物理列类型(键)映射到抽象列类型(值)

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_TINYINT'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]

方法详情

createQueryBuilder() 公共 方法

为 MSSQL 数据库创建查询构建器。

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

查询构建器接口。

createSavepoint() 公共 方法

Creates a new savepoint.

public void createSavepoint($name)
$name string

The savepoint name

findColumns() 受保护 方法

收集表列的元数据。

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

表元数据

return boolean

表是否存在于数据库中

findForeignKeys() 受保护 方法

收集外键列详细信息。

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

表元数据

findPrimaryKeys() 受保护 方法

收集给定表的主键列详细信息。

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

表元数据

findSchemaNames() 受保护 方法

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.

参见 https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-database-principals-transact-sql.

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.

findTableConstraints() 受保护 方法 (自版本 2.0.4 可用)

收集给定表和约束类型的约束详细信息。

protected array findTableConstraints($table, $type)
$table yii\db\mssql\TableSchema
$type string

PRIMARY KEY 和 UNIQUE 任选其一

return array

每个条目都包含的 index_name 和 field_name

findTableNames() 受保护 方法

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() 公共 方法 (自版本 2.0.4 可用)

返回给定表的所有唯一索引。

每个数组元素都具有以下结构:

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

表元数据

return array

给定表的所有唯一索引。

findViewNames() 受保护 方法

protected void findViewNames($schema '')
$schema
loadColumnSchema() 受保护 方法

将列信息加载到 yii\db\ColumnSchema 对象中。

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

列信息

return yii\db\ColumnSchema

列数据库结构对象

loadTableChecks() 受保护 方法

protected void loadTableChecks($tableName)
$tableName
loadTableDefaultValues() 受保护 方法

protected void loadTableDefaultValues($tableName)
$tableName
loadTableForeignKeys() 受保护 方法

protected void loadTableForeignKeys($tableName)
$tableName
loadTableIndexes() 受保护 方法

protected void loadTableIndexes($tableName)
$tableName
loadTablePrimaryKey() 受保护 方法

protected void loadTablePrimaryKey($tableName)
$tableName
loadTableSchema() 受保护 方法

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 void loadTableUniques($tableName)
$tableName
releaseSavepoint() 公共 方法

Releases an existing savepoint.

public void releaseSavepoint($name)
$name string

The savepoint name

resolveTableName() 受保护 方法

解析表名和数据库结构名称(如果存在的话)。

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

表名

return yii\db\mssql\TableSchema

解析表、数据库结构等名称。

resolveTableNames() 受保护 方法

解析表名和数据结构名称(如果存在的话)。

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

表元数据对象

$name string

表名

rollBackSavepoint() 公共 方法

Rolls back to a previously created savepoint.

public void rollBackSavepoint($name)
$name string

The savepoint name