Documentation

Schema extends Schema
in package
Uses SchemaTrait

Command class represents a SQL statement to be executed against a database.

Table of Contents

$_tableNames  : array<string|int, mixed>
createColumnSchemaBuilder()  : ColumnSchemaBuilder
Create a column schema builder instance giving the type and value precision.
createSavepoint()  : mixed
Creates a new savepoint.
findForeignKeyToColumn()  : array<string|int, mixed>
Find foreign keys to column.
getRawTableName()  : string
Returns the actual name of a given table name.
getTableIndexes()  : array<string|int, IndexConstraint>
Lists indexes for table.
getTableNames()  : array<string|int, string>
Returns all table names in the database.
refresh()  : mixed
Refreshes the schema.
refreshTableSchema()  : mixed
Refreshes the particular table schema.
releaseSavepoint()  : mixed
Releases an existing savepoint.
rollBackSavepoint()  : mixed
Rolls back to a previously created savepoint.
setTransactionIsolationLevel()  : mixed
Sets the isolation level of the current transaction.
getTableMetadata()  : mixed
Returns the metadata of the given type for the given table.
setTableMetadata()  : mixed
Sets the metadata of the given type for the given table.

Properties

$_tableNames

private array<string|int, mixed> $_tableNames = []

list of ALL table names in the database

Methods

createColumnSchemaBuilder()

Create a column schema builder instance giving the type and value precision.

public createColumnSchemaBuilder(string $type[, array<string|int, mixed>|int|string $length = null ]) : ColumnSchemaBuilder

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

Parameters
$type : string

type of the column. See [[ColumnSchemaBuilder::$type]].

$length : array<string|int, mixed>|int|string = null

length or precision of the column. See [[ColumnSchemaBuilder::$length]].

Tags
since
2.0.6
Return values
ColumnSchemaBuilder —

column schema builder instance

createSavepoint()

Creates a new savepoint.

public createSavepoint(string $name) : mixed
Parameters
$name : string

the savepoint name

Return values
mixed —

findForeignKeyToColumn()

Find foreign keys to column.

public findForeignKeyToColumn(string $findTableName, string $findColumnName) : array<string|int, mixed>
Parameters
$findTableName : string
$findColumnName : string
Return values
array<string|int, mixed> —

getRawTableName()

Returns the actual name of a given table name.

public getRawTableName(string $name) : string

This method will strip off curly brackets from the given table name and replace the percentage character '%' with [[Connection::tablePrefix]].

Parameters
$name : string

the table name to be converted

Return values
string —

the real name of the given table name

getTableIndexes()

Lists indexes for table.

public getTableIndexes(string $name[, bool $refresh = false ]) : array<string|int, IndexConstraint>
Parameters
$name : string
$refresh : bool = false
Return values
array<string|int, IndexConstraint> —

getTableNames()

Returns all table names in the database.

public getTableNames([string $schema = '' ][, bool $refresh = false ]) : array<string|int, string>
Parameters
$schema : string = ''

the schema of the tables. Defaults to empty string, meaning the current or default schema name. If not empty, the returned table names will be prefixed with the schema name.

$refresh : bool = false

whether to fetch the latest available table names. If this is false, table names fetched previously (if available) will be returned.

Return values
array<string|int, string> —

all table names in the database.

refresh()

Refreshes the schema.

public refresh() : mixed

This method cleans up all cached table schemas so that they can be re-created later to reflect the database schema change.

Return values
mixed —

refreshTableSchema()

Refreshes the particular table schema.

public refreshTableSchema(string $name) : mixed

This method cleans up cached table schema so that it can be re-created later to reflect the database schema change.

Parameters
$name : string

table name.

Tags
since
2.0.6
Return values
mixed —

releaseSavepoint()

Releases an existing savepoint.

public releaseSavepoint(string $name) : mixed
Parameters
$name : string

the savepoint name

Return values
mixed —

rollBackSavepoint()

Rolls back to a previously created savepoint.

public rollBackSavepoint(string $name) : mixed
Parameters
$name : string

the savepoint name

Return values
mixed —

setTransactionIsolationLevel()

Sets the isolation level of the current transaction.

public setTransactionIsolationLevel(string $level) : mixed
Parameters
$level : string

The transaction isolation level to use for this transaction. This can be one of [[Transaction::READ_UNCOMMITTED]], [[Transaction::READ_COMMITTED]], [[Transaction::REPEATABLE_READ]] and [[Transaction::SERIALIZABLE]] but also a string containing DBMS specific syntax to be used after SET TRANSACTION ISOLATION LEVEL.

Tags
see
https://en.wikipedia.org/wiki/Isolation_%28database_systems%29#Isolation_levels
Return values
mixed —

getTableMetadata()

Returns the metadata of the given type for the given table.

protected getTableMetadata(string $name, string $type, bool $refresh) : mixed

If there's no metadata in the cache, this method will call a 'loadTable' . ucfirst($type) named method with the table name to obtain the metadata.

Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$type : string

metadata type.

$refresh : bool

whether to reload the table metadata even if it is found in the cache.

Tags
since
2.0.13
Return values
mixed —

metadata.

setTableMetadata()

Sets the metadata of the given type for the given table.

protected setTableMetadata(string $name, string $type, mixed $data) : mixed
Parameters
$name : string

table name.

$type : string

metadata type.

$data : mixed

metadata.

Tags
since
2.0.13
Return values
mixed —

        

Search results