Trait yii\db\ConstraintFinderTrait
| Implemented by | yii\ |
|---|---|
| Available since version | 2.0.13 |
| Source Code | https://github.com/yiisoft/yii2/blob/master/framework/db/ConstraintFinderTrait.php |
ConstraintFinderTrait provides methods for getting a table constraint information.
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $schemaChecks | yii\ |
Check constraints for all tables in the database. | yii\ |
| $schemaDefaultValues | yii\ |
Default value constraints for all tables in the database. | yii\ |
| $schemaForeignKeys | yii\ |
Foreign keys for all tables in the database. | yii\ |
| $schemaIndexes | yii\ |
Indexes for all tables in the database. | yii\ |
| $schemaPrimaryKeys | yii\ |
Primary keys for all tables in the database. | yii\ |
| $schemaUniques | yii\ |
Unique constraints for all tables in the database. | yii\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getSchemaChecks() | Returns check constraints for all tables in the database. | yii\ |
| getSchemaDefaultValues() | Returns default value constraints for all tables in the database. | yii\ |
| getSchemaForeignKeys() | Returns foreign keys for all tables in the database. | yii\ |
| getSchemaIndexes() | Returns indexes for all tables in the database. | yii\ |
| getSchemaPrimaryKeys() | Returns primary keys for all tables in the database. | yii\ |
| getSchemaUniques() | Returns unique constraints for all tables in the database. | yii\ |
| getTableChecks() | Obtains the check constraints information for the named table. | yii\ |
| getTableDefaultValues() | Obtains the default value constraints information for the named table. | yii\ |
| getTableForeignKeys() | Obtains the foreign keys information for the named table. | yii\ |
| getTableIndexes() | Obtains the indexes information for the named table. | yii\ |
| getTablePrimaryKey() | Obtains the primary key for the named table. | yii\ |
| getTableUniques() | Obtains the unique constraints information for the named table. | yii\ |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| getSchemaMetadata() | Returns the metadata of the given type for all tables in the given schema. | yii\ |
| getTableMetadata() | Returns the metadata of the given type for the given table. | yii\ |
| loadTableChecks() | Loads all check constraints for the given table. | yii\ |
| loadTableDefaultValues() | Loads all default value constraints for the given table. | yii\ |
| loadTableForeignKeys() | Loads all foreign keys for the given table. | yii\ |
| loadTableIndexes() | Loads all indexes for the given table. | yii\ |
| loadTablePrimaryKey() | Loads a primary key for the given table. | yii\ |
| loadTableUniques() | Loads all unique constraints for the given table. | yii\ |
Property Details
Check constraints for all tables in the database.
Each array element is an array of yii\
Default value constraints for all tables in the database.
Each array element is an array of yii\
Foreign keys for all tables in the database.
Each
array element is an array of yii\
Indexes for all tables in the database.
Each array element is
an array of yii\
Primary keys for all tables in the database.
Each array element
is an instance of yii\
Unique constraints for all tables in the database.
Each array element is an array of yii\
Method Details
Returns check constraints for all tables in the database.
| public getSchemaChecks( string $schema = '', boolean $refresh = false ): yii\ | ||
| $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 | yii\ |
Check constraints for all tables in the database.
Each array element is an array of yii\ |
|---|---|---|
public function getSchemaChecks($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'checks', $refresh);
}
Returns default value constraints for all tables in the database.
| public getSchemaDefaultValues( string $schema = '', boolean $refresh = false ): yii\ | ||
| $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 | yii\ |
Default value constraints for all tables in the database.
Each array element is an array of yii\ |
|---|---|---|
public function getSchemaDefaultValues($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'defaultValues', $refresh);
}
Returns foreign keys for all tables in the database.
| public getSchemaForeignKeys( string $schema = '', boolean $refresh = false ): yii\ | ||
| $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 | yii\ |
Foreign keys for all tables in the database.
Each array element is an array of yii\ |
|---|---|---|
public function getSchemaForeignKeys($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'foreignKeys', $refresh);
}
Returns indexes for all tables in the database.
| public getSchemaIndexes( string $schema = '', boolean $refresh = false ): yii\ | ||
| $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 | yii\ |
Indexes for all tables in the database.
Each array element is an array of yii\ |
|---|---|---|
public function getSchemaIndexes($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'indexes', $refresh);
}
Returns the metadata of the given type for all tables in the given schema.
| protected abstract getSchemaMetadata( string $schema, string $type, boolean $refresh ): array | ||
| $schema | string |
The schema of the metadata. Defaults to empty string, meaning the current or default schema name. |
| $type | string |
Metadata type. |
| $refresh | boolean |
Whether to fetch the latest available table metadata. If this is |
| return | array |
Array of metadata. |
|---|---|---|
abstract protected function getSchemaMetadata($schema, $type, $refresh);
Returns primary keys for all tables in the database.
| public getSchemaPrimaryKeys( string $schema = '', boolean $refresh = false ): yii\ | ||
| $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 |
| return | yii\ |
Primary keys for all tables in the database.
Each array element is an instance of yii\ |
|---|---|---|
public function getSchemaPrimaryKeys($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'primaryKey', $refresh);
}
Returns unique constraints for all tables in the database.
| public getSchemaUniques( string $schema = '', boolean $refresh = false ): yii\ | ||
| $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 | yii\ |
Unique constraints for all tables in the database.
Each array element is an array of yii\ |
|---|---|---|
public function getSchemaUniques($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'uniques', $refresh);
}
Obtains the check constraints information for the named table.
| public getTableChecks( string $name, boolean $refresh = false ): yii\ | ||
| $name | string |
Table name. The table name may contain schema name if any. Do not quote the table name. |
| $refresh | boolean |
Whether to reload the information even if it is found in the cache. |
| return | yii\ |
Table check constraints. |
|---|---|---|
public function getTableChecks($name, $refresh = false)
{
return $this->getTableMetadata($name, 'checks', $refresh);
}
Obtains the default value constraints information for the named table.
| public getTableDefaultValues( string $name, boolean $refresh = false ): yii\ | ||
| $name | string |
Table name. The table name may contain schema name if any. Do not quote the table name. |
| $refresh | boolean |
Whether to reload the information even if it is found in the cache. |
| return | yii\ |
Table default value constraints. |
|---|---|---|
public function getTableDefaultValues($name, $refresh = false)
{
return $this->getTableMetadata($name, 'defaultValues', $refresh);
}
Obtains the foreign keys information for the named table.
| public getTableForeignKeys( string $name, boolean $refresh = false ): yii\ | ||
| $name | string |
Table name. The table name may contain schema name if any. Do not quote the table name. |
| $refresh | boolean |
Whether to reload the information even if it is found in the cache. |
| return | yii\ |
Table foreign keys. |
|---|---|---|
public function getTableForeignKeys($name, $refresh = false)
{
return $this->getTableMetadata($name, 'foreignKeys', $refresh);
}
Obtains the indexes information for the named table.
| public getTableIndexes( string $name, boolean $refresh = false ): yii\ | ||
| $name | string |
Table name. The table name may contain schema name if any. Do not quote the table name. |
| $refresh | boolean |
Whether to reload the information even if it is found in the cache. |
| return | yii\ |
Table indexes. |
|---|---|---|
public function getTableIndexes($name, $refresh = false)
{
return $this->getTableMetadata($name, 'indexes', $refresh);
}
Returns the metadata of the given type for the given table.
| protected abstract getTableMetadata( string $name, string $type, boolean $refresh ): mixed | ||
| $name | string |
Table name. The table name may contain schema name if any. Do not quote the table name. |
| $type | string |
Metadata type. |
| $refresh | boolean |
Whether to reload the table metadata even if it is found in the cache. |
| return | mixed |
Metadata. |
|---|---|---|
abstract protected function getTableMetadata($name, $type, $refresh);
Obtains the primary key for the named table.
| public getTablePrimaryKey( string $name, boolean $refresh = false ): yii\ | ||
| $name | string |
Table name. The table name may contain schema name if any. Do not quote the table name. |
| $refresh | boolean |
Whether to reload the information even if it is found in the cache. |
| return | yii\ |
Table primary key, |
|---|---|---|
public function getTablePrimaryKey($name, $refresh = false)
{
return $this->getTableMetadata($name, 'primaryKey', $refresh);
}
Obtains the unique constraints information for the named table.
| public getTableUniques( string $name, boolean $refresh = false ): yii\ | ||
| $name | string |
Table name. The table name may contain schema name if any. Do not quote the table name. |
| $refresh | boolean |
Whether to reload the information even if it is found in the cache. |
| return | yii\ |
Table unique constraints. |
|---|---|---|
public function getTableUniques($name, $refresh = false)
{
return $this->getTableMetadata($name, 'uniques', $refresh);
}
Loads all check constraints for the given table.
| protected abstract loadTableChecks( string $tableName ): yii\ | ||
| $tableName | string |
Table name. |
| return | yii\ |
Check constraints for the given table. |
|---|---|---|
abstract protected function loadTableChecks($tableName);
Loads all default value constraints for the given table.
| protected abstract loadTableDefaultValues( string $tableName ): yii\ | ||
| $tableName | string |
Table name. |
| return | yii\ |
Default value constraints for the given table. |
|---|---|---|
abstract protected function loadTableDefaultValues($tableName);
Loads all foreign keys for the given table.
| protected abstract loadTableForeignKeys( string $tableName ): yii\ | ||
| $tableName | string |
Table name. |
| return | yii\ |
Foreign keys for the given table. |
|---|---|---|
abstract protected function loadTableForeignKeys($tableName);
Loads all indexes for the given table.
| protected abstract loadTableIndexes( string $tableName ): yii\ | ||
| $tableName | string |
Table name. |
| return | yii\ |
Indexes for the given table. |
|---|---|---|
abstract protected function loadTableIndexes($tableName);
Loads a primary key for the given table.
| protected abstract loadTablePrimaryKey( string $tableName ): yii\ | ||
| $tableName | string |
Table name. |
| return | yii\ |
Primary key for the given table, |
|---|---|---|
abstract protected function loadTablePrimaryKey($tableName);
Loads all unique constraints for the given table.
| protected abstract loadTableUniques( string $tableName ): yii\ | ||
| $tableName | string |
Table name. |
| return | yii\ |
Unique constraints for the given table. |
|---|---|---|
abstract protected function loadTableUniques($tableName);