0 follower

Interface Yiisoft\Db\Schema\SchemaInterface

ExtendsYiisoft\Db\Constraint\ConstraintSchemaInterface
Implemented byYiisoft\Db\Driver\Pdo\AbstractPdoSchema, Yiisoft\Db\Schema\AbstractSchema

Represents the schema for a database table.

It provides a set of methods for working with the schema of a database table, such as accessing the columns, indexes, and constraints of a table, as well as methods for creating, dropping, and altering tables.

Public Methods

Hide inherited methods

Method Description Defined By
enableCache() Enable or disable the schema cache. Yiisoft\Db\Schema\SchemaInterface
getDataType() Determines the SQL data type for the given PHP data value. Yiisoft\Db\Schema\SchemaInterface
getDefaultSchema() Yiisoft\Db\Schema\SchemaInterface
getResultColumn() Returns the column instance for the column metadata received from the query result. Yiisoft\Db\Schema\SchemaInterface
getSchemaChecks() Returns check constraints for all tables in the database. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getSchemaDefaultValues() Returns default value constraints for all tables in the database. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getSchemaForeignKeys() Returns foreign keys for all tables in the database. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getSchemaIndexes() Returns indexes for all tables in the database. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getSchemaNames() Returns all schema names in the database, except system schemas. Yiisoft\Db\Schema\SchemaInterface
getSchemaPrimaryKeys() Returns primary keys for all tables in the database. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getSchemaUniques() Returns unique constraints for all tables in the database. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getTableChecks() Obtains the check constraints' information for the named table. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getTableDefaultValues() Obtains the default value constraints information for the named table. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getTableForeignKeys() Obtains the foreign keys' information for the named table. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getTableIndexes() Obtains the indexes' information for the named table. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getTableNames() Returns all table names in the database. Yiisoft\Db\Schema\SchemaInterface
getTablePrimaryKey() Obtains the primary key for the named table. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getTableSchema() Obtains the metadata for the named table. Yiisoft\Db\Schema\SchemaInterface
getTableSchemas() Returns the metadata for all tables in the database. Yiisoft\Db\Schema\SchemaInterface
getTableUniques() Obtains the unique constraints' information for the named table. Yiisoft\Db\Constraint\ConstraintSchemaInterface
getViewNames() Returns all view names in the database. Yiisoft\Db\Schema\SchemaInterface
hasSchema() Determines if a specified schema exists in the database. Yiisoft\Db\Schema\SchemaInterface
hasTable() Determines if a specified table exists in the database. Yiisoft\Db\Schema\SchemaInterface
hasView() Determines if a specified view exists in the database. Yiisoft\Db\Schema\SchemaInterface
refresh() Refreshes the schema. Yiisoft\Db\Schema\SchemaInterface
refreshTableSchema() Refreshes the particular table schema. Yiisoft\Db\Schema\SchemaInterface

Constants

Hide inherited constants

Constant Value Description Defined By
CHECKS 'checks' The metadata type for retrieving the check constraint. Yiisoft\Db\Schema\SchemaInterface
DEFAULTS 'defaults' The metadata type for retrieving the default constraint. Yiisoft\Db\Schema\SchemaInterface
DEFAULT_VALUES 'defaultValues' The metadata type for retrieving the default values constraint. Yiisoft\Db\Schema\SchemaInterface
FOREIGN_KEYS 'foreignKeys' The metadata type for retrieving the foreign key constraints. Yiisoft\Db\Schema\SchemaInterface
INDEXES 'indexes' The metadata type for retrieving the index constraints. Yiisoft\Db\Schema\SchemaInterface
PRIMARY_KEY 'primaryKey' The metadata type for retrieving the primary key constraint. Yiisoft\Db\Schema\SchemaInterface
SCHEMA 'schema' The metadata type for retrieving the table schema. Yiisoft\Db\Schema\SchemaInterface
UNIQUES 'uniques' The metadata type for retrieving the unique constraints. Yiisoft\Db\Schema\SchemaInterface

Method Details

Hide inherited methods

enableCache() public abstract method

Enable or disable the schema cache.

public abstract void enableCache ( boolean $value )
$value boolean

Whether to enable or disable the schema cache.

                public function enableCache(bool $value): void;

            
getDataType() public abstract method

Determines the SQL data type for the given PHP data value.

public abstract integer getDataType ( mixed $data )
$data mixed

The data to find a type for.

return integer

The type.

                public function getDataType(mixed $data): int;

            
getDefaultSchema() public abstract method

public abstract string getDefaultSchema ( )
return string

The default schema name.

                public function getDefaultSchema(): string;

            
getResultColumn() public abstract method

Returns the column instance for the column metadata received from the query result.

public abstract Yiisoft\Db\Schema\Column\ColumnInterface|null getResultColumn ( array $metadata )
$metadata array

The column metadata from the query result.

                public function getResultColumn(array $metadata): ?ColumnInterface;

            
getSchemaChecks() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getSchemaChecks()

Returns check constraints for all tables in the database.

public abstract Yiisoft\Db\Constraint\Check[] getSchemaChecks ( string $schema '', boolean $refresh false )
$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return Yiisoft\Db\Constraint\Check[]

The check constraints for all tables in the database.

                public function getSchemaChecks(string $schema = '', bool $refresh = false): array;

            
getSchemaDefaultValues() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getSchemaDefaultValues()

Returns default value constraints for all tables in the database.

public abstract Yiisoft\Db\Constraint\DefaultValue[] getSchemaDefaultValues ( string $schema '', boolean $refresh false )
$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return Yiisoft\Db\Constraint\DefaultValue[]

The default value constraints for all tables in the database.

                public function getSchemaDefaultValues(string $schema = '', bool $refresh = false): array;

            
getSchemaForeignKeys() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getSchemaForeignKeys()

Returns foreign keys for all tables in the database.

public abstract Yiisoft\Db\Constraint\ForeignKey[] getSchemaForeignKeys ( string $schema '', boolean $refresh false )
$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return Yiisoft\Db\Constraint\ForeignKey[]

The foreign keys for all tables in the database.

                public function getSchemaForeignKeys(string $schema = '', bool $refresh = false): array;

            
getSchemaIndexes() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getSchemaIndexes()

Returns indexes for all tables in the database.

public abstract Yiisoft\Db\Constraint\Index[] getSchemaIndexes ( string $schema '', boolean $refresh false )
$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return Yiisoft\Db\Constraint\Index[]

The indexes for all tables in the database.

                public function getSchemaIndexes(string $schema = '', bool $refresh = false): array;

            
getSchemaNames() public abstract method

Returns all schema names in the database, except system schemas.

public abstract string[] getSchemaNames ( boolean $refresh false )
$refresh boolean

Whether to fetch the latest available schema names. If this is false, schema names fetched before (if available) will be returned.

return string[]

All schemas name in the database, except system schemas.

                public function getSchemaNames(bool $refresh = false): array;

            
getSchemaPrimaryKeys() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getSchemaPrimaryKeys()

Returns primary keys for all tables in the database.

public abstract Yiisoft\Db\Constraint\Index[] getSchemaPrimaryKeys ( string $schema '', boolean $refresh false )
$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return Yiisoft\Db\Constraint\Index[]

The primary keys for all tables in the database.

                public function getSchemaPrimaryKeys(string $schema = '', bool $refresh = false): array;

            
getSchemaUniques() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getSchemaUniques()

Returns unique constraints for all tables in the database.

public abstract Yiisoft\Db\Constraint\Index[] getSchemaUniques ( string $schema '', boolean $refresh false )
$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return Yiisoft\Db\Constraint\Index[]

The unique constraints for all tables in the database.

                public function getSchemaUniques(string $schema = '', bool $refresh = false): array;

            
getTableChecks() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getTableChecks()

Obtains the check constraints' information for the named table.

public abstract Yiisoft\Db\Constraint\Check[] getTableChecks ( string $name, boolean $refresh false )
$name string

Table name. The table name may contain a schema name if any. Don't quote the table name.

$refresh boolean

Whether to reload the information, even if it's found in the cache.

return Yiisoft\Db\Constraint\Check[]

The information metadata for the check constraints of the named table.

                public function getTableChecks(string $name, bool $refresh = false): array;

            
getTableDefaultValues() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getTableDefaultValues()

Obtains the default value constraints information for the named table.

public abstract Yiisoft\Db\Constraint\DefaultValue[] getTableDefaultValues ( string $name, boolean $refresh false )
$name string

Table name. The table name may contain a schema name if any. Don't quote the table name.

$refresh boolean

Whether to reload the information, even if it's found in the cache.

return Yiisoft\Db\Constraint\DefaultValue[]

The information metadata for the default value constraints of the named table.

                public function getTableDefaultValues(string $name, bool $refresh = false): array;

            
getTableForeignKeys() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getTableForeignKeys()

Obtains the foreign keys' information for the named table.

public abstract Yiisoft\Db\Constraint\ForeignKey[] getTableForeignKeys ( string $name, boolean $refresh false )
$name string

Table name. The table name may contain a schema name if any. Don't quote the table name.

$refresh boolean

Whether to reload the information, even if it's found in the cache.

return Yiisoft\Db\Constraint\ForeignKey[]

The information metadata for the foreign keys of the named table.

                public function getTableForeignKeys(string $name, bool $refresh = false): array;

            
getTableIndexes() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getTableIndexes()

Obtains the indexes' information for the named table.

public abstract Yiisoft\Db\Constraint\Index[] getTableIndexes ( string $name, boolean $refresh false )
$name string

Table name. The table name may contain a schema name if any. Don't quote the table name.

$refresh boolean

Whether to reload the information, even if it's found in the cache.

return Yiisoft\Db\Constraint\Index[]

The information metadata for the indexes of the named table.

                public function getTableIndexes(string $name, bool $refresh = false): array;

            
getTableNames() public abstract method

Returns all table names in the database.

public abstract string[] getTableNames ( string $schema '', boolean $refresh false )
$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 boolean

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

return string[]

All tables name in the database.

                public function getTableNames(string $schema = '', bool $refresh = false): array;

            
getTablePrimaryKey() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getTablePrimaryKey()

Obtains the primary key for the named table.

public abstract Yiisoft\Db\Constraint\Index|null getTablePrimaryKey ( string $name, boolean $refresh false )
$name string

Table name. The table name may contain a schema name if any. Don't quote the table name.

$refresh boolean

Whether to reload the information, even if it's found in the cache.

return Yiisoft\Db\Constraint\Index|null

The information metadata for the primary key of the named table.

                public function getTablePrimaryKey(string $name, bool $refresh = false): ?Index;

            
getTableSchema() public abstract method

Obtains the metadata for the named table.

public abstract Yiisoft\Db\Schema\TableSchemaInterface|null getTableSchema ( string $name, boolean $refresh false )
$name string

Table name. The table name may contain a schema name if any. Don't quote the table name.

$refresh boolean

Whether to reload the table schema even if it's found in the cache.

return Yiisoft\Db\Schema\TableSchemaInterface|null

Table metadata. null if the named table doesn't exist.

                public function getTableSchema(string $name, bool $refresh = false): ?TableSchemaInterface;

            
getTableSchemas() public abstract method

Returns the metadata for all tables in the database.

public abstract Yiisoft\Db\Schema\TableSchemaInterface[] getTableSchemas ( string $schema '', boolean $refresh false )
$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return Yiisoft\Db\Schema\TableSchemaInterface[]

The metadata for all tables in the database.

                public function getTableSchemas(string $schema = '', bool $refresh = false): array;

            
getTableUniques() public abstract method

Defined in: Yiisoft\Db\Constraint\ConstraintSchemaInterface::getTableUniques()

Obtains the unique constraints' information for the named table.

public abstract Yiisoft\Db\Constraint\Index[] getTableUniques ( string $name, boolean $refresh false )
$name string

Table name. The table name may contain a schema name if any. Don't quote the table name.

$refresh boolean

Whether to reload the information, even if it's found in the cache.

return Yiisoft\Db\Constraint\Index[]

The information metadata for the unique constraints of the named table.

                public function getTableUniques(string $name, bool $refresh = false): array;

            
getViewNames() public abstract method

Returns all view names in the database.

public abstract string[] getViewNames ( string $schema '', boolean $refresh false )
$schema string

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

$refresh boolean

Whether to fetch the latest available view names. If this is false, view names fetched before (if available) will be returned.

return string[]

All view names in the database.

                public function getViewNames(string $schema = '', bool $refresh = false): array;

            
hasSchema() public abstract method

Determines if a specified schema exists in the database.

public abstract boolean hasSchema ( string $schema, boolean $refresh false )
$schema string

The schema name to search for

$refresh boolean

Whether to fetch the latest available schema names. If this is false, view names fetched before (if available) will be returned.

return boolean

Whether schema exists.

                public function hasSchema(string $schema, bool $refresh = false): bool;

            
hasTable() public abstract method

Determines if a specified table exists in the database.

public abstract boolean hasTable ( string $tableName, string $schema '', boolean $refresh false )
$tableName string

The table name to search for

$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name. If not empty, the table will be searched in the specified schema.

$refresh boolean

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

return boolean

Whether table exists.

                public function hasTable(string $tableName, string $schema = '', bool $refresh = false): bool;

            
hasView() public abstract method

Determines if a specified view exists in the database.

public abstract boolean hasView ( string $viewName, string $schema '', boolean $refresh false )
$viewName string

The view name to search for

$schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name. If not empty, the table will be searched in the specified schema.

$refresh boolean

Whether to fetch the latest available view names. If this is false, view names fetched before (if available) will be returned.

return boolean

Whether view exists.

                public function hasView(string $viewName, string $schema = '', bool $refresh = false): bool;

            
refresh() public abstract method

Refreshes the schema.

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

public abstract void refresh ( )

                public function refresh(): void;

            
refreshTableSchema() public abstract method

Refreshes the particular table schema.

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

public abstract void refreshTableSchema ( string $name )
$name string

Table name.

                public function refreshTableSchema(string $name): void;