Class yii\db\oci\Schema
Schema 类用于从 Oracle 数据库检索元数据。
公共属性
属性 | 类型 | 描述 | 被定义在 |
---|---|---|---|
$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 name used for the current session. | yii\db\Schema |
$exceptionMap | array | 数据库错误和相应异常的映射 如果在 DB 错误消息中找到映射关系的左侧部分,则使用右侧部分的异常类。 | yii\db\oci\Schema |
$lastInsertID | string | 插入的最后一行的行 ID,或从序列对象检索的最后一个值 | yii\db\oci\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 |
受保护的属性
属性 | 类型 | 描述 | 被定义在 |
---|---|---|---|
$columnQuoteCharacter | string|string[] | Character used to quote column names. | yii\db\Schema |
$tableQuoteCharacter | string|string[] | Character used to quote schema, table, etc. | yii\db\oci\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\oci\Schema |
createQueryBuilder() | Creates a query builder for the database. | yii\db\oci\Schema |
createSavepoint() | Creates a new savepoint. | yii\db\Schema |
findUniqueIndexes() | 返回给定表的所有唯一索引。 每个数组元素都类似如下结构:。 | yii\db\oci\Schema |
getLastInsertID() | yii\db\oci\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 |
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\db\oci\Schema |
insert() | Executes the INSERT command, returning primary key values. | yii\db\oci\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\oci\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\oci\Schema |
rollBackSavepoint() | Rolls back to a previously created savepoint. | yii\db\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 |
受保护的方法
常量
常量 | 值 | 描述 | 被定义在 |
---|---|---|---|
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 |
属性详情
数据库错误和相应异常的映射 如果在 DB 错误消息中找到映射关系的左侧部分,则使用右侧部分的异常类。
插入的最后一行的行 ID,或从序列对象检索的最后一个值
Character used to quote schema, table, etc. names. An array of 2 characters can be used in case starting and ending characters are different.
方法详情
创建 ColumnSchema 实例。
protected yii\db\ColumnSchema createColumn($column) | ||
$column | array |
Create a column schema builder instance giving the type and value precision.
This method may be overridden by child classes to create a DBMS-specific column schema builder.
public yii\db\ColumnSchemaBuilder createColumnSchemaBuilder($type, $length = null) | ||
$type | string | Type of the column. See yii\db\oci\ColumnSchemaBuilder::$type. |
$length | integer|string|array | Length or precision of the column. See yii\db\oci\ColumnSchemaBuilder::$length. |
return | yii\db\ColumnSchemaBuilder | Column schema builder instance |
---|
Creates a query builder for the database.
This method may be overridden by child classes to create a DBMS-specific query builder.
public yii\db\QueryBuilder createQueryBuilder() | ||
return | yii\db\QueryBuilder | Query builder instance |
---|
从列的 DB 类型中提取大小、精度和比例信息。
protected void extractColumnSize($column, $dbType, $precision, $scale, $length) | ||
$column | yii\db\ColumnSchema | |
$dbType | string | 列的 DB 类型 |
$precision | string | 总位数。 此参数从 2.0.4 版本开始支持。 |
$scale | string | 小数点分隔符右侧的位数。 此参数从 2.0.4 版本开始支持。 |
$length | string | 字符类型的长度。 此参数从 2.0.4 版本开始支持。 |
提取给定列的数据类型。
protected void extractColumnType($column, $dbType, $precision, $scale, $length) | ||
$column | yii\db\ColumnSchema | |
$dbType | string | DB 类型 |
$precision | string | 总位数。 此参数从 2.0.4 版本开始支持。 |
$scale | string | 小数点分隔符右侧的位数。 此参数从 2.0.4 版本开始支持。 |
$length | string | 字符类型的长度。 此参数从 2.0.4 版本开始支持。 |
搜集表元数据。
protected boolean findColumns($table) | ||
$table | yii\db\TableSchema | 表结构 |
return | boolean | 表是否存在 |
---|
查找约束,并将它们填充到传递的 TableSchema 对象中。
protected void findConstraints($table) | ||
$table | yii\db\TableSchema |
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.oracle.com/cd/B28359_01/server.111/b28337/tdpsg_user_accounts.htm.
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. |
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. |
返回给定表的所有唯一索引。 每个数组元素都类似如下结构:。
[
'IndexName1' => ['col1' [, ...]],
'IndexName2' => ['col2' [, ...]],
]
public array findUniqueIndexes($table) | ||
$table | yii\db\TableSchema | 表元数据 |
return | array | 给定表的所有唯一索引。 |
---|
参见 http://www.php.net/manual/en/function.PDO-lastInsertId.php -> Oracle 不支持这一点 返回最后插入的行或序列的 ID。.
public string getLastInsertID($sequenceName = '') | ||
$sequenceName | string | 序列对象的名称 (required by some DBMS) |
return | string | 插入的最后一行的行 ID,或从序列对象检索的最后一个值 |
---|---|---|
throws | yii\base\InvalidCallException | 如果 DB 连接处于非活动状态,则抛出异常 |
表的序列名称。
protected string|null getTableSequenceName($tableName) | ||
$tableName | string | |
return | string|null | 表序列是否存在 |
---|
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
public void init() |
Executes the INSERT command, returning primary key values.
public array|false insert($table, $columns) | ||
$table | string | The table that new rows will be inserted into. |
$columns | array | The column data (name => value) to be inserted into the table. |
return | array|false | Primary key values or false if the command fails |
---|
protected void loadTableChecks($tableName) | ||
$tableName |
protected void loadTableDefaultValues($tableName) | ||
$tableName | ||
throws | yii\base\NotSupportedException | 如果调用此方法,则抛出异常。 |
---|
protected void loadTableForeignKeys($tableName) | ||
$tableName |
protected void loadTableIndexes($tableName) | ||
$tableName |
protected void loadTablePrimaryKey($tableName) | ||
$tableName |
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, |
---|
protected void loadTableUniques($tableName) | ||
$tableName |
Quotes a simple table name for use in a query.
A simple table name should contain the table name only without any schema prefix. If the table name is already quoted, this method will do nothing.
public string quoteSimpleTableName($name) | ||
$name | string | Table name |
return | string | The properly quoted table name |
---|
Releases an existing savepoint.
public void releaseSavepoint($name) | ||
$name | string | The savepoint name |
Resolves the table name and schema name (if any).
protected yii\db\TableSchema resolveTableName($name) | ||
$name | string | The table name |
return | yii\db\TableSchema | yii\db\TableSchema with resolved table, schema, etc. names. |
---|---|---|
throws | yii\base\NotSupportedException | if this method is not supported by the DBMS. |
解析表名和数据库结构名称(如果有的话)。
protected void resolveTableNames($table, $name) | ||
$table | yii\db\TableSchema | 表元数据对象 |
$name | string | 表名 |