Skip to content
PHP Ecosystem
Explore

Schema

API reference › yii › db › oci › Schema

Schema is the class for retrieving metadata from an Oracle database.

PropertyTypeDescriptionDefined by
$columnSchemaClassclass-string<yii\db\T>|array{class?: class-string<yii\db\T>, __class?: class-string<yii\db\T>}Default: \yii\db\oci\ColumnSchema::class. Available since 2.0.11.Schema
$dbyii\db\ConnectionThe database connection Default: null.yii\db\Schema
$defaultSchemastringThe default schema name used for the current session. Default: null.yii\db\Schema
$exceptionMaparrayMap of DB errors and corresponding exceptions If left part is found in DB error message exception class from the right part is used. Default: ['ORA-00001: unique constraint' => \yii\db\IntegrityException::class].Schema
$lastInsertID read-onlystringThe row ID of the last row inserted, or the last value retrieved from the sequence object.Schema
$queryBuilder read-onlyyii\db\TQueryBuilderThe query builder for this connection.yii\db\Schema
$schemaChecks read-onlyyii\db\CheckConstraint[][]Check constraints for all tables in the database.yii\db\ConstraintFinderTrait
$schemaDefaultValues read-onlyyii\db\DefaultValueConstraint[]Default value constraints for all tables in the database.yii\db\ConstraintFinderTrait
$schemaForeignKeys read-onlyyii\db\ForeignKeyConstraint[][]Foreign keys for all tables in the database.yii\db\ConstraintFinderTrait
$schemaIndexes read-onlyyii\db\IndexConstraint[][]Indexes for all tables in the database.yii\db\ConstraintFinderTrait
$schemaNames read-onlystring[]All schema names in the database, except system schemas.yii\db\Schema
$schemaPrimaryKeys read-onlyyii\db\Constraint[]Primary keys for all tables in the database.yii\db\ConstraintFinderTrait
$schemaUniques read-onlyyii\db\IndexConstraint[][]Unique constraints for all tables in the database.yii\db\ConstraintFinderTrait
$serverVersion read-onlystringServer version as a string.yii\db\Schema
$systemSchemaNameslist<string>List of schema names that should be excluded from getSchemaNames(). Default: [].yii\db\Schema
$tableNames read-onlystring[]All table names in the database.yii\db\Schema
$tableSchemas read-onlyyii\db\TableSchema[]The metadata for all tables in the database.yii\db\Schema
$transactionIsolationLevel write-onlystringThe transaction isolation level to use for this transaction.yii\db\Schema
$columnQuoteCharacter protectedstring|string[]Character used to quote column names. Default: '"'. Available since 2.0.14.yii\db\Schema
$tableQuoteCharacter protectedstring|string[]Default: '"'. Available since 2.0.14.Schema
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.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() staticReturns 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.Schema
createQueryBuilder()Creates a query builder for the database.Schema
createSavepoint()Creates a new savepoint.yii\db\Schema
findUniqueIndexes()Returns all unique indexes for the given table.Schema
getLastInsertID()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.Schema
insert()Executes the INSERT command, returning primary key values.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.Schema
resolveRawTableName()Resolves the table name and schema name (if any) without loading database metadata.yii\db\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
createColumn() protectedCreates ColumnSchema instance.Schema
createColumnSchema() protectedCreates a column schema for the database.yii\db\Schema
extractColumnSize() protectedExtracts size, precision and scale information from column’s DB type.Schema
extractColumnType() protectedExtracts the data types for the given column.Schema
findColumns() protectedCollects the table column metadata.Schema
findConstraints() protectedFinds constraints and fills them into TableSchema object passed.Schema
findSchemaNames() protectedReturns all schema names in the database, including the default one but not system schemas.Schema
findTableNames() protectedReturns all table names in the database.Schema
getCacheKey() protectedReturns the cache key for the specified table name.yii\db\Schema
getCacheTag() protectedReturns the cache tag name.yii\db\Schema
getColumnPhpType() protectedExtracts the PHP type from abstract DB type.yii\db\Schema
getSchemaMetadata() protectedReturns the metadata of the given type for all tables in the given schema.yii\db\Schema
getTableMetadata() protectedReturns the metadata of the given type for the given table.yii\db\Schema
getTableNameParts() protectedSplits full table name into parts.yii\db\Schema
getTableSequenceName() protectedSequence name of table.Schema
loadTableChecks() protectedSchema
loadTableDefaultValues() protectedSchema
loadTableForeignKeys() protectedSchema
loadTableIndexes() protectedSchema
loadTablePrimaryKey() protectedSchema
loadTableSchema() protectedLoads the metadata for the specified table.Schema
loadTableUniques() protectedSchema
normalizePdoRowKeyCase() protectedChanges row’s array key case to lower if PDO’s one is set to uppercase.yii\db\Schema
resolveTableName() protectedResolves the table name and schema name (if any).Schema
setTableMetadata() protectedSets the metadata of the given type for the given table.yii\db\Schema
protected string|string[] $tableQuoteCharacter = '"'

An array of 2 characters can be used in case starting and ending characters are different.

Since

2.0.14

public function createColumnSchemaBuilder(mixed $type, mixed $length = null): yii\db\ColumnSchemaBuilder

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.

Parameters

ParameterTypeDescription
$typemixedType of the column. See ColumnSchemaBuilder::$type.
$lengthmixedLength or precision of the column. See ColumnSchemaBuilder::$length.

Returns

yii\db\ColumnSchemaBuilder: Column schema builder instance

Since

2.0.6

public function createQueryBuilder(): yii\db\TQueryBuilder

Creates a query builder for the database.

This method may be overridden by child classes to create a DBMS-specific query builder.

Returns

yii\db\TQueryBuilder: Query builder instance

public function findUniqueIndexes(yii\db\TableSchema $table): array

Returns all unique indexes for the given table.

Each array element is of the following structure:

[
'IndexName1' => ['col1' [, ...]],
'IndexName2' => ['col2' [, ...]],
]

Parameters

ParameterTypeDescription
$tableyii\db\TableSchemaThe table metadata.

Returns

array: All unique indexes for the given table.

Since

2.0.4

public function getLastInsertID(string $sequenceName = ''): string

Parameters

ParameterTypeDescription
$sequenceNamestringName 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

See also

public function init(): mixed

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

Returns

mixed

public function insert(mixed $table, mixed $columns): array|false

Executes the INSERT command, returning primary key values.

Merges primary-key and BLOB locator entries into one Oracle RETURNING clause.

Parameters

ParameterTypeDescription
$tablemixedThe table that new rows will be inserted into.
$columnsmixedThe column data (name => value) to be inserted into the table.

Returns

array|false: Primary key values or false if the command fails

Since

2.0.4

public function releaseSavepoint(mixed $name): mixed

Releases an existing savepoint.

Parameters

ParameterTypeDescription
$namemixedThe savepoint name

Returns

mixed

protected function createColumn(array $column): yii\db\oci\T

Creates ColumnSchema instance.

Parameters

ParameterTypeDescription
$columnarray

Returns

yii\db\oci\T

protected function extractColumnSize(yii\db\oci\ColumnSchema $column, string $dbType, string $precision, string $scale, string $length): mixed

Extracts size, precision and scale information from column’s DB type.

Parameters

ParameterTypeDescription
$columnColumnSchema
$dbTypestringThe column’s DB type
$precisionstringTotal number of digits. This parameter is available since version 2.0.4.
$scalestringNumber of digits on the right of the decimal separator. This parameter is available since version 2.0.4.
$lengthstringLength for character types. This parameter is available since version 2.0.4.

Returns

mixed

protected function extractColumnType(yii\db\oci\ColumnSchema $column, string $dbType, string $precision, string $scale, string $length): mixed

Extracts the data types for the given column.

Parameters

ParameterTypeDescription
$columnColumnSchema
$dbTypestringDB type
$precisionstringTotal number of digits. This parameter is available since version 2.0.4.
$scalestringNumber of digits on the right of the decimal separator. This parameter is available since version 2.0.4.
$lengthstringLength for character types. This parameter is available since version 2.0.4.

Returns

mixed

protected function findColumns(yii\db\TableSchema $table): bool

Collects the table column metadata.

Parameters

ParameterTypeDescription
$tableyii\db\TableSchemaThe table schema.

Returns

bool: Whether the table exists.

protected function findConstraints(yii\db\TableSchema $table): mixed

Finds constraints and fills them into TableSchema object passed.

Parameters

ParameterTypeDescription
$tableyii\db\TableSchema

Returns

mixed

protected function findSchemaNames(): array

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.

Returns

array: All schema names in the database, except system schemas.

Throws

Since

2.0.4

See also

protected function findTableNames(mixed $schema = ''): array

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.

Parameters

ParameterTypeDescription
$schemamixedThe schema of the tables. Defaults to empty string, meaning the current or default schema.

Returns

array: All table names in the database. The names have NO schema name prefix.

Throws

protected function getTableSequenceName(string $tableName): string|null

Sequence name of table.

Resolves the sequence backing the table’s primary key, supporting two storage idioms:

  • IDENTITY columns (Oracle 12.1+): returns the system-generated ISEQ$$_* sequence from USER_TAB_IDENTITY_COLS. Surfaced so framework machinery that reads \yii\db\TableSchema::$sequenceName (notably \yii\test\ActiveFixture::resetTable()) continues to work for tables created with Schema::TYPE_PK.
  • Legacy trigger + sequence pairs (pre-22.0): falls back to the USER_DEPENDENCIES / USER_TRIGGERS join so applications that have not yet migrated their tables continue to expose the user-named sequence.

Parameters

ParameterTypeDescription
$tableNamestringTable name.

Returns

string|null: Whether the sequence exists.

protected function loadTableChecks(mixed $tableName)

Parameters

ParameterTypeDescription
$tableNamemixed
protected function loadTableDefaultValues(mixed $tableName)

Parameters

ParameterTypeDescription
$tableNamemixed

Throws

protected function loadTableForeignKeys(mixed $tableName)

Parameters

ParameterTypeDescription
$tableNamemixed
protected function loadTableIndexes(mixed $tableName)

Parameters

ParameterTypeDescription
$tableNamemixed
protected function loadTablePrimaryKey(mixed $tableName)

Parameters

ParameterTypeDescription
$tableNamemixed
protected function loadTableSchema(mixed $name): yii\db\TableSchema|null

Loads the metadata for the specified table.

Parameters

ParameterTypeDescription
$namemixedTable name

Returns

yii\db\TableSchema|null: DBMS-dependent table metadata, null if the table does not exist.

protected function loadTableUniques(mixed $tableName)

Parameters

ParameterTypeDescription
$tableNamemixed
protected function resolveTableName(mixed $name): yii\db\TableSchema

Resolves the table name and schema name (if any).

Parameters

ParameterTypeDescription
$namemixedThe table name

Returns

yii\db\TableSchema: TableSchema with resolved table, schema, etc. names.

Throws

Since

2.0.13