Skip to content
PHP Ecosystem
Explore

ConstraintFinderTrait

API reference › yii › db › ConstraintFinderTrait

traityii\db\ConstraintFinderTrait
Since2.0.13
Sourceframework/db/ConstraintFinderTrait.php
Used by 5 types

ConstraintFinderTrait provides methods for getting a table constraint information.

PropertyTypeDescriptionDefined by
$schemaChecksCheckConstraint[][]Check constraints for all tables in the database.ConstraintFinderTrait
$schemaDefaultValuesDefaultValueConstraint[]Default value constraints for all tables in the database.ConstraintFinderTrait
$schemaForeignKeysForeignKeyConstraint[][]Foreign keys for all tables in the database.ConstraintFinderTrait
$schemaIndexesIndexConstraint[][]Indexes for all tables in the database.ConstraintFinderTrait
$schemaPrimaryKeysConstraint[]Primary keys for all tables in the database.ConstraintFinderTrait
$schemaUniquesIndexConstraint[][]Unique constraints for all tables in the database.ConstraintFinderTrait
MethodDescriptionDefined by
getSchemaChecks()Returns check constraints for all tables in the database.ConstraintFinderTrait
getSchemaDefaultValues()Returns default value constraints for all tables in the database.ConstraintFinderTrait
getSchemaForeignKeys()Returns foreign keys for all tables in the database.ConstraintFinderTrait
getSchemaIndexes()Returns indexes for all tables in the database.ConstraintFinderTrait
getSchemaPrimaryKeys()Returns primary keys for all tables in the database.ConstraintFinderTrait
getSchemaUniques()Returns unique constraints for all tables in the database.ConstraintFinderTrait
getTableChecks()Obtains the check constraints information for the named table.ConstraintFinderTrait
getTableDefaultValues()Obtains the default value constraints information for the named table.ConstraintFinderTrait
getTableForeignKeys()Obtains the foreign keys information for the named table.ConstraintFinderTrait
getTableIndexes()Obtains the indexes information for the named table.ConstraintFinderTrait
getTablePrimaryKey()Obtains the primary key for the named table.ConstraintFinderTrait
getTableUniques()Obtains the unique constraints information for the named table.ConstraintFinderTrait
getSchemaMetadata() protected abstractReturns the metadata of the given type for all tables in the given schema.ConstraintFinderTrait
getTableMetadata() protected abstractReturns the metadata of the given type for the given table.ConstraintFinderTrait
loadTableChecks() protected abstractLoads all check constraints for the given table.ConstraintFinderTrait
loadTableDefaultValues() protected abstractLoads all default value constraints for the given table.ConstraintFinderTrait
loadTableForeignKeys() protected abstractLoads all foreign keys for the given table.ConstraintFinderTrait
loadTableIndexes() protected abstractLoads all indexes for the given table.ConstraintFinderTrait
loadTablePrimaryKey() protected abstractLoads a primary key for the given table.ConstraintFinderTrait
loadTableUniques() protected abstractLoads all unique constraints for the given table.ConstraintFinderTrait
public yii\db\CheckConstraint[][] $schemaChecks

Check constraints for all tables in the database.

Each array element is an array of CheckConstraint or its child classes. This property is read-only.

public yii\db\DefaultValueConstraint[] $schemaDefaultValues

Default value constraints for all tables in the database.

Each array element is an array of DefaultValueConstraint or its child classes. This property is read-only.

public yii\db\ForeignKeyConstraint[][] $schemaForeignKeys

Foreign keys for all tables in the database.

Each array element is an array of ForeignKeyConstraint or its child classes. This property is read-only.

public yii\db\IndexConstraint[][] $schemaIndexes

Indexes for all tables in the database.

Each array element is an array of IndexConstraint or its child classes. This property is read-only.

public yii\db\Constraint[] $schemaPrimaryKeys

Primary keys for all tables in the database.

Each array element is an instance of Constraint or its child class. This property is read-only.

public yii\db\IndexConstraint[][] $schemaUniques

Unique constraints for all tables in the database.

Each array element is an array of IndexConstraint or its child classes. This property is read-only.

public function getSchemaChecks(string $schema = '', bool $refresh = false): yii\db\CheckConstraint[][]

Returns check constraints for all tables in the database.

Parameters

ParameterTypeDescription
$schemastringThe schema of the tables. Defaults to empty string, meaning the current or default schema name.
$refreshboolWhether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

Returns

CheckConstraint[][]: Check constraints for all tables in the database. Each array element is an array of CheckConstraint or its child classes.

public function getSchemaDefaultValues(string $schema = '', bool $refresh = false): yii\db\DefaultValueConstraint[]

Returns default value constraints for all tables in the database.

Parameters

ParameterTypeDescription
$schemastringThe schema of the tables. Defaults to empty string, meaning the current or default schema name.
$refreshboolWhether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

Returns

DefaultValueConstraint[]: Default value constraints for all tables in the database. Each array element is an array of DefaultValueConstraint or its child classes.

public function getSchemaForeignKeys(string $schema = '', bool $refresh = false): yii\db\ForeignKeyConstraint[][]

Returns foreign keys for all tables in the database.

Parameters

ParameterTypeDescription
$schemastringThe schema of the tables. Defaults to empty string, meaning the current or default schema name.
$refreshboolWhether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

Returns

ForeignKeyConstraint[][]: Foreign keys for all tables in the database. Each array element is an array of ForeignKeyConstraint or its child classes.

public function getSchemaIndexes(string $schema = '', bool $refresh = false): yii\db\IndexConstraint[][]

Returns indexes for all tables in the database.

Parameters

ParameterTypeDescription
$schemastringThe schema of the tables. Defaults to empty string, meaning the current or default schema name.
$refreshboolWhether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

Returns

IndexConstraint[][]: Indexes for all tables in the database. Each array element is an array of IndexConstraint or its child classes.

public function getSchemaPrimaryKeys(string $schema = '', bool $refresh = false): yii\db\Constraint[]

Returns primary keys for all tables in the database.

Parameters

ParameterTypeDescription
$schemastringThe schema of the tables. Defaults to empty string, meaning the current or default schema name.
$refreshboolWhether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

Returns

Constraint[]: Primary keys for all tables in the database. Each array element is an instance of Constraint or its child class.

public function getSchemaUniques(string $schema = '', bool $refresh = false): yii\db\Constraint[][]

Returns unique constraints for all tables in the database.

Parameters

ParameterTypeDescription
$schemastringThe schema of the tables. Defaults to empty string, meaning the current or default schema name.
$refreshboolWhether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

Returns

Constraint[][]: Unique constraints for all tables in the database. Each array element is an array of Constraint or its child classes.

public function getTableChecks(string $name, bool $refresh = false): yii\db\CheckConstraint[]

Obtains the check constraints information for the named table.

Parameters

ParameterTypeDescription
$namestringTable name. The table name may contain schema name if any. Do not quote the table name.
$refreshboolWhether to reload the information even if it is found in the cache.

Returns

CheckConstraint[]: Table check constraints.

public function getTableDefaultValues(string $name, bool $refresh = false): yii\db\DefaultValueConstraint[]

Obtains the default value constraints information for the named table.

Parameters

ParameterTypeDescription
$namestringTable name. The table name may contain schema name if any. Do not quote the table name.
$refreshboolWhether to reload the information even if it is found in the cache.

Returns

DefaultValueConstraint[]: Table default value constraints.

public function getTableForeignKeys(string $name, bool $refresh = false): yii\db\ForeignKeyConstraint[]

Obtains the foreign keys information for the named table.

Parameters

ParameterTypeDescription
$namestringTable name. The table name may contain schema name if any. Do not quote the table name.
$refreshboolWhether to reload the information even if it is found in the cache.

Returns

ForeignKeyConstraint[]: Table foreign keys.

public function getTableIndexes(string $name, bool $refresh = false): yii\db\IndexConstraint[]

Obtains the indexes information for the named table.

Parameters

ParameterTypeDescription
$namestringTable name. The table name may contain schema name if any. Do not quote the table name.
$refreshboolWhether to reload the information even if it is found in the cache.

Returns

IndexConstraint[]: Table indexes.

public function getTablePrimaryKey(string $name, bool $refresh = false): yii\db\Constraint|null

Obtains the primary key for the named table.

Parameters

ParameterTypeDescription
$namestringTable name. The table name may contain schema name if any. Do not quote the table name.
$refreshboolWhether to reload the information even if it is found in the cache.

Returns

Constraint|null: Table primary key, null if the table has no primary key.

public function getTableUniques(string $name, bool $refresh = false): yii\db\Constraint[]

Obtains the unique constraints information for the named table.

Parameters

ParameterTypeDescription
$namestringTable name. The table name may contain schema name if any. Do not quote the table name.
$refreshboolWhether to reload the information even if it is found in the cache.

Returns

Constraint[]: Table unique constraints.

abstract protected function getSchemaMetadata(string $schema, string $type, bool $refresh): array

Returns the metadata of the given type for all tables in the given schema.

Parameters

ParameterTypeDescription
$schemastringThe schema of the metadata. Defaults to empty string, meaning the current or default schema name.
$typestringMetadata type.
$refreshboolWhether to fetch the latest available table metadata. If this is false, cached data may be returned if available.

Returns

array: Array of metadata.

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

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

Parameters

ParameterTypeDescription
$namestringTable name. The table name may contain schema name if any. Do not quote the table name.
$typestringMetadata type.
$refreshboolWhether to reload the table metadata even if it is found in the cache.

Returns

mixed: Metadata.

abstract protected function loadTableChecks(string $tableName): yii\db\CheckConstraint[]

Loads all check constraints for the given table.

Parameters

ParameterTypeDescription
$tableNamestringTable name.

Returns

CheckConstraint[]: Check constraints for the given table.

abstract protected function loadTableDefaultValues(string $tableName): yii\db\DefaultValueConstraint[]

Loads all default value constraints for the given table.

Parameters

ParameterTypeDescription
$tableNamestringTable name.

Returns

DefaultValueConstraint[]: Default value constraints for the given table.

abstract protected function loadTableForeignKeys(string $tableName): yii\db\ForeignKeyConstraint[]

Loads all foreign keys for the given table.

Parameters

ParameterTypeDescription
$tableNamestringTable name.

Returns

ForeignKeyConstraint[]: Foreign keys for the given table.

abstract protected function loadTableIndexes(string $tableName): yii\db\IndexConstraint[]

Loads all indexes for the given table.

Parameters

ParameterTypeDescription
$tableNamestringTable name.

Returns

IndexConstraint[]: Indexes for the given table.

abstract protected function loadTablePrimaryKey(string $tableName): yii\db\Constraint|null

Loads a primary key for the given table.

Parameters

ParameterTypeDescription
$tableNamestringTable name.

Returns

Constraint|null: Primary key for the given table, null if the table has no primary key.

abstract protected function loadTableUniques(string $tableName): yii\db\Constraint[]

Loads all unique constraints for the given table.

Parameters

ParameterTypeDescription
$tableNamestringTable name.

Returns

Constraint[]: Unique constraints for the given table.