ConstraintFinderTrait
API reference › yii › db › ConstraintFinderTrait
Used by 5 types
ConstraintFinderTrait provides methods for getting a table constraint information.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$schemaChecks | CheckConstraint[][] | Check constraints for all tables in the database. | ConstraintFinderTrait |
$schemaDefaultValues | DefaultValueConstraint[] | Default value constraints for all tables in the database. | ConstraintFinderTrait |
$schemaForeignKeys | ForeignKeyConstraint[][] | Foreign keys for all tables in the database. | ConstraintFinderTrait |
$schemaIndexes | IndexConstraint[][] | Indexes for all tables in the database. | ConstraintFinderTrait |
$schemaPrimaryKeys | Constraint[] | Primary keys for all tables in the database. | ConstraintFinderTrait |
$schemaUniques | IndexConstraint[][] | Unique constraints for all tables in the database. | ConstraintFinderTrait |
Methods
Section titled “Methods”| Method | Description | Defined 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 abstract | Returns the metadata of the given type for all tables in the given schema. | ConstraintFinderTrait |
getTableMetadata() protected abstract | Returns the metadata of the given type for the given table. | ConstraintFinderTrait |
loadTableChecks() protected abstract | Loads all check constraints for the given table. | ConstraintFinderTrait |
loadTableDefaultValues() protected abstract | Loads all default value constraints for the given table. | ConstraintFinderTrait |
loadTableForeignKeys() protected abstract | Loads all foreign keys for the given table. | ConstraintFinderTrait |
loadTableIndexes() protected abstract | Loads all indexes for the given table. | ConstraintFinderTrait |
loadTablePrimaryKey() protected abstract | Loads a primary key for the given table. | ConstraintFinderTrait |
loadTableUniques() protected abstract | Loads all unique constraints for the given table. | ConstraintFinderTrait |
Property details
Section titled “Property details”$schemaChecks
Section titled “$schemaChecks ”public yii\db\CheckConstraint[][] $schemaChecksCheck constraints for all tables in the database.
Each array element is an array of CheckConstraint or its child classes. This property is read-only.
$schemaDefaultValues
Section titled “$schemaDefaultValues ”public yii\db\DefaultValueConstraint[] $schemaDefaultValuesDefault 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.
$schemaForeignKeys
Section titled “$schemaForeignKeys ”public yii\db\ForeignKeyConstraint[][] $schemaForeignKeysForeign keys for all tables in the database.
Each
array element is an array of ForeignKeyConstraint or its child classes. This property is read-only.
$schemaIndexes
Section titled “$schemaIndexes ”public yii\db\IndexConstraint[][] $schemaIndexesIndexes for all tables in the database.
Each array element is
an array of IndexConstraint or its child classes. This property is read-only.
$schemaPrimaryKeys
Section titled “$schemaPrimaryKeys ”public yii\db\Constraint[] $schemaPrimaryKeysPrimary keys for all tables in the database.
Each array element
is an instance of Constraint or its child class. This property is read-only.
$schemaUniques
Section titled “$schemaUniques ”public yii\db\IndexConstraint[][] $schemaUniquesUnique constraints for all tables in the database.
Each array element is an array of IndexConstraint or its child classes. This property is read-only.
Method details
Section titled “Method details”getSchemaChecks()
Section titled “getSchemaChecks() ”public function getSchemaChecks(string $schema = '', bool $refresh = false): yii\db\CheckConstraint[][]Returns check constraints for all tables in the database.
Parameters
| Parameter | Type | Description |
|---|---|---|
$schema | string | The schema of the tables. Defaults to empty string, meaning the current or default schema name. |
$refresh | bool | Whether 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.
getSchemaDefaultValues()
Section titled “getSchemaDefaultValues() ”public function getSchemaDefaultValues(string $schema = '', bool $refresh = false): yii\db\DefaultValueConstraint[]Returns default value constraints for all tables in the database.
Parameters
| Parameter | Type | Description |
|---|---|---|
$schema | string | The schema of the tables. Defaults to empty string, meaning the current or default schema name. |
$refresh | bool | Whether 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.
getSchemaForeignKeys()
Section titled “getSchemaForeignKeys() ”public function getSchemaForeignKeys(string $schema = '', bool $refresh = false): yii\db\ForeignKeyConstraint[][]Returns foreign keys for all tables in the database.
Parameters
| Parameter | Type | Description |
|---|---|---|
$schema | string | The schema of the tables. Defaults to empty string, meaning the current or default schema name. |
$refresh | bool | Whether 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.
getSchemaIndexes()
Section titled “getSchemaIndexes() ”public function getSchemaIndexes(string $schema = '', bool $refresh = false): yii\db\IndexConstraint[][]Returns indexes for all tables in the database.
Parameters
| Parameter | Type | Description |
|---|---|---|
$schema | string | The schema of the tables. Defaults to empty string, meaning the current or default schema name. |
$refresh | bool | Whether 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.
getSchemaPrimaryKeys()
Section titled “getSchemaPrimaryKeys() ”public function getSchemaPrimaryKeys(string $schema = '', bool $refresh = false): yii\db\Constraint[]Returns primary keys for all tables in the database.
Parameters
| Parameter | Type | Description |
|---|---|---|
$schema | string | The schema of the tables. Defaults to empty string, meaning the current or default schema name. |
$refresh | bool | Whether 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.
getSchemaUniques()
Section titled “getSchemaUniques() ”public function getSchemaUniques(string $schema = '', bool $refresh = false): yii\db\Constraint[][]Returns unique constraints for all tables in the database.
Parameters
| Parameter | Type | Description |
|---|---|---|
$schema | string | The schema of the tables. Defaults to empty string, meaning the current or default schema name. |
$refresh | bool | Whether 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.
getTableChecks()
Section titled “getTableChecks() ”public function getTableChecks(string $name, bool $refresh = false): yii\db\CheckConstraint[]Obtains the check constraints information for the named table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Table name. The table name may contain schema name if any. Do not quote the table name. |
$refresh | bool | Whether to reload the information even if it is found in the cache. |
Returns
CheckConstraint[]: Table check constraints.
getTableDefaultValues()
Section titled “getTableDefaultValues() ”public function getTableDefaultValues(string $name, bool $refresh = false): yii\db\DefaultValueConstraint[]Obtains the default value constraints information for the named table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Table name. The table name may contain schema name if any. Do not quote the table name. |
$refresh | bool | Whether to reload the information even if it is found in the cache. |
Returns
DefaultValueConstraint[]: Table default value constraints.
getTableForeignKeys()
Section titled “getTableForeignKeys() ”public function getTableForeignKeys(string $name, bool $refresh = false): yii\db\ForeignKeyConstraint[]Obtains the foreign keys information for the named table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Table name. The table name may contain schema name if any. Do not quote the table name. |
$refresh | bool | Whether to reload the information even if it is found in the cache. |
Returns
ForeignKeyConstraint[]: Table foreign keys.
getTableIndexes()
Section titled “getTableIndexes() ”public function getTableIndexes(string $name, bool $refresh = false): yii\db\IndexConstraint[]Obtains the indexes information for the named table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Table name. The table name may contain schema name if any. Do not quote the table name. |
$refresh | bool | Whether to reload the information even if it is found in the cache. |
Returns
IndexConstraint[]: Table indexes.
getTablePrimaryKey()
Section titled “getTablePrimaryKey() ”public function getTablePrimaryKey(string $name, bool $refresh = false): yii\db\Constraint|nullObtains the primary key for the named table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Table name. The table name may contain schema name if any. Do not quote the table name. |
$refresh | bool | Whether 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.
getTableUniques()
Section titled “getTableUniques() ”public function getTableUniques(string $name, bool $refresh = false): yii\db\Constraint[]Obtains the unique constraints information for the named table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Table name. The table name may contain schema name if any. Do not quote the table name. |
$refresh | bool | Whether to reload the information even if it is found in the cache. |
Returns
Constraint[]: Table unique constraints.
getSchemaMetadata()
Section titled “getSchemaMetadata() ”abstract protected function getSchemaMetadata(string $schema, string $type, bool $refresh): arrayReturns the metadata of the given type for all tables in the given schema.
Parameters
| Parameter | Type | Description |
|---|---|---|
$schema | string | The schema of the metadata. Defaults to empty string, meaning the current or default schema name. |
$type | string | Metadata type. |
$refresh | bool | Whether to fetch the latest available table metadata. If this is false, cached data may be returned if available. |
Returns
array: Array of metadata.
getTableMetadata()
Section titled “getTableMetadata() ”abstract protected function getTableMetadata(string $name, string $type, bool $refresh): mixedReturns the metadata of the given type for the given table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$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. |
Returns
mixed: Metadata.
loadTableChecks()
Section titled “loadTableChecks() ”abstract protected function loadTableChecks(string $tableName): yii\db\CheckConstraint[]Loads all check constraints for the given table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tableName | string | Table name. |
Returns
CheckConstraint[]: Check constraints for the given table.
loadTableDefaultValues()
Section titled “loadTableDefaultValues() ”abstract protected function loadTableDefaultValues(string $tableName): yii\db\DefaultValueConstraint[]Loads all default value constraints for the given table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tableName | string | Table name. |
Returns
DefaultValueConstraint[]: Default value constraints for the given table.
loadTableForeignKeys()
Section titled “loadTableForeignKeys() ”abstract protected function loadTableForeignKeys(string $tableName): yii\db\ForeignKeyConstraint[]Loads all foreign keys for the given table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tableName | string | Table name. |
Returns
ForeignKeyConstraint[]: Foreign keys for the given table.
loadTableIndexes()
Section titled “loadTableIndexes() ”abstract protected function loadTableIndexes(string $tableName): yii\db\IndexConstraint[]Loads all indexes for the given table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tableName | string | Table name. |
Returns
IndexConstraint[]: Indexes for the given table.
loadTablePrimaryKey()
Section titled “loadTablePrimaryKey() ”abstract protected function loadTablePrimaryKey(string $tableName): yii\db\Constraint|nullLoads a primary key for the given table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tableName | string | Table name. |
Returns
Constraint|null: Primary key for the given table, null if the table has no primary key.
loadTableUniques()
Section titled “loadTableUniques() ”abstract protected function loadTableUniques(string $tableName): yii\db\Constraint[]Loads all unique constraints for the given table.
Parameters
| Parameter | Type | Description |
|---|---|---|
$tableName | string | Table name. |
Returns
Constraint[]: Unique constraints for the given table.