0 follower

Trait yii\db\ConstraintFinderTrait

Implemented byyii\db\cubrid\Schema, yii\db\mssql\Schema, yii\db\mysql\Schema, yii\db\oci\Schema, yii\db\pgsql\Schema, yii\db\sqlite\Schema
Available since version2.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

Hide inherited properties

Property Type Description Defined By
$schemaChecks yii\db\CheckConstraint[][] Check constraints for all tables in the database. yii\db\ConstraintFinderTrait
$schemaDefaultValues yii\db\DefaultValueConstraint[] Default value constraints for all tables in the database. yii\db\ConstraintFinderTrait
$schemaForeignKeys yii\db\ForeignKeyConstraint[][] Foreign keys for all tables in the database. yii\db\ConstraintFinderTrait
$schemaIndexes yii\db\IndexConstraint[][] Indexes for all tables in the database. yii\db\ConstraintFinderTrait
$schemaPrimaryKeys yii\db\Constraint[] Primary keys for all tables in the database. yii\db\ConstraintFinderTrait
$schemaUniques yii\db\IndexConstraint[][] Unique constraints for all tables in the database. yii\db\ConstraintFinderTrait

Public Methods

Hide inherited methods

Method Description Defined By
getSchemaChecks() Returns check constraints for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaDefaultValues() Returns default value constraints for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaForeignKeys() Returns foreign keys for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaIndexes() Returns indexes for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaPrimaryKeys() Returns primary keys for all tables in the database. yii\db\ConstraintFinderTrait
getSchemaUniques() Returns unique constraints for all tables in the database. yii\db\ConstraintFinderTrait
getTableChecks() Obtains the check constraints information for the named table. yii\db\ConstraintFinderTrait
getTableDefaultValues() Obtains the default value constraints information for the named table. yii\db\ConstraintFinderTrait
getTableForeignKeys() Obtains the foreign keys information for the named table. yii\db\ConstraintFinderTrait
getTableIndexes() Obtains the indexes information for the named table. yii\db\ConstraintFinderTrait
getTablePrimaryKey() Obtains the primary key for the named table. yii\db\ConstraintFinderTrait
getTableUniques() Obtains the unique constraints information for the named table. yii\db\ConstraintFinderTrait

Protected Methods

Hide inherited methods

Method Description Defined By
getSchemaMetadata() Returns the metadata of the given type for all tables in the given schema. yii\db\ConstraintFinderTrait
getTableMetadata() Returns the metadata of the given type for the given table. yii\db\ConstraintFinderTrait
loadTableChecks() Loads all check constraints for the given table. yii\db\ConstraintFinderTrait
loadTableDefaultValues() Loads all default value constraints for the given table. yii\db\ConstraintFinderTrait
loadTableForeignKeys() Loads all foreign keys for the given table. yii\db\ConstraintFinderTrait
loadTableIndexes() Loads all indexes for the given table. yii\db\ConstraintFinderTrait
loadTablePrimaryKey() Loads a primary key for the given table. yii\db\ConstraintFinderTrait
loadTableUniques() Loads all unique constraints for the given table. yii\db\ConstraintFinderTrait

Property Details

Hide inherited properties

$schemaChecks public property

Check constraints for all tables in the database. Each array element is an array of yii\db\CheckConstraint or its child classes. This property is read-only.

$schemaDefaultValues public property

Default value constraints for all tables in the database. Each array element is an array of yii\db\DefaultValueConstraint or its child classes. This property is read-only.

$schemaForeignKeys public property

Foreign keys for all tables in the database. Each array element is an array of yii\db\ForeignKeyConstraint or its child classes. This property is read-only.

$schemaIndexes public property

Indexes for all tables in the database. Each array element is an array of yii\db\IndexConstraint or its child classes. This property is read-only.

$schemaPrimaryKeys public property

Primary keys for all tables in the database. Each array element is an instance of yii\db\Constraint or its child class. This property is read-only.

$schemaUniques public property

Unique constraints for all tables in the database. Each array element is an array of yii\db\IndexConstraint or its child classes. This property is read-only.

Method Details

Hide inherited methods

getSchemaChecks() public method

Returns check constraints for all tables in the database.

public getSchemaChecks( string $schema '', boolean $refresh false ): yii\db\CheckConstraint[][]
$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\db\CheckConstraint[][]

Check constraints for all tables in the database. Each array element is an array of yii\db\CheckConstraint or its child classes.

                public function getSchemaChecks($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'checks', $refresh);
}

            
getSchemaDefaultValues() public method

Returns default value constraints for all tables in the database.

public getSchemaDefaultValues( string $schema '', boolean $refresh false ): yii\db\DefaultValueConstraint[]
$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\db\DefaultValueConstraint[]

Default value constraints for all tables in the database. Each array element is an array of yii\db\DefaultValueConstraint or its child classes.

                public function getSchemaDefaultValues($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'defaultValues', $refresh);
}

            
getSchemaForeignKeys() public method

Returns foreign keys for all tables in the database.

public getSchemaForeignKeys( string $schema '', boolean $refresh false ): yii\db\ForeignKeyConstraint[][]
$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\db\ForeignKeyConstraint[][]

Foreign keys for all tables in the database. Each array element is an array of yii\db\ForeignKeyConstraint or its child classes.

                public function getSchemaForeignKeys($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'foreignKeys', $refresh);
}

            
getSchemaIndexes() public method

Returns indexes for all tables in the database.

public getSchemaIndexes( string $schema '', boolean $refresh false ): yii\db\IndexConstraint[][]
$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\db\IndexConstraint[][]

Indexes for all tables in the database. Each array element is an array of yii\db\IndexConstraint or its child classes.

                public function getSchemaIndexes($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'indexes', $refresh);
}

            
getSchemaMetadata() protected abstract method

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 false, cached data may be returned if available.

return array

Array of metadata.

                abstract protected function getSchemaMetadata($schema, $type, $refresh);

            
getSchemaPrimaryKeys() public method

Returns primary keys for all tables in the database.

public getSchemaPrimaryKeys( string $schema '', boolean $refresh false ): yii\db\Constraint[]
$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\db\Constraint[]

Primary keys for all tables in the database. Each array element is an instance of yii\db\Constraint or its child class.

                public function getSchemaPrimaryKeys($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'primaryKey', $refresh);
}

            
getSchemaUniques() public method

Returns unique constraints for all tables in the database.

public getSchemaUniques( string $schema '', boolean $refresh false ): yii\db\Constraint[][]
$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\db\Constraint[][]

Unique constraints for all tables in the database. Each array element is an array of yii\db\Constraint or its child classes.

                public function getSchemaUniques($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'uniques', $refresh);
}

            
getTableChecks() public method

Obtains the check constraints information for the named table.

public getTableChecks( string $name, boolean $refresh false ): yii\db\CheckConstraint[]
$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\db\CheckConstraint[]

Table check constraints.

                public function getTableChecks($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'checks', $refresh);
}

            
getTableDefaultValues() public method

Obtains the default value constraints information for the named table.

public getTableDefaultValues( string $name, boolean $refresh false ): yii\db\DefaultValueConstraint[]
$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\db\DefaultValueConstraint[]

Table default value constraints.

                public function getTableDefaultValues($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'defaultValues', $refresh);
}

            
getTableForeignKeys() public method

Obtains the foreign keys information for the named table.

public getTableForeignKeys( string $name, boolean $refresh false ): yii\db\ForeignKeyConstraint[]
$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\db\ForeignKeyConstraint[]

Table foreign keys.

                public function getTableForeignKeys($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'foreignKeys', $refresh);
}

            
getTableIndexes() public method

Obtains the indexes information for the named table.

public getTableIndexes( string $name, boolean $refresh false ): yii\db\IndexConstraint[]
$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\db\IndexConstraint[]

Table indexes.

                public function getTableIndexes($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'indexes', $refresh);
}

            
getTableMetadata() protected abstract method

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);

            
getTablePrimaryKey() public method

Obtains the primary key for the named table.

public getTablePrimaryKey( string $name, boolean $refresh false ): yii\db\Constraint|null
$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\db\Constraint|null

Table primary key, null if the table has no primary key.

                public function getTablePrimaryKey($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'primaryKey', $refresh);
}

            
getTableUniques() public method

Obtains the unique constraints information for the named table.

public getTableUniques( string $name, boolean $refresh false ): yii\db\Constraint[]
$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\db\Constraint[]

Table unique constraints.

                public function getTableUniques($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'uniques', $refresh);
}

            
loadTableChecks() protected abstract method

Loads all check constraints for the given table.

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

Table name.

return yii\db\CheckConstraint[]

Check constraints for the given table.

                abstract protected function loadTableChecks($tableName);

            
loadTableDefaultValues() protected abstract method

Loads all default value constraints for the given table.

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

Table name.

return yii\db\DefaultValueConstraint[]

Default value constraints for the given table.

                abstract protected function loadTableDefaultValues($tableName);

            
loadTableForeignKeys() protected abstract method

Loads all foreign keys for the given table.

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

Table name.

return yii\db\ForeignKeyConstraint[]

Foreign keys for the given table.

                abstract protected function loadTableForeignKeys($tableName);

            
loadTableIndexes() protected abstract method

Loads all indexes for the given table.

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

Table name.

return yii\db\IndexConstraint[]

Indexes for the given table.

                abstract protected function loadTableIndexes($tableName);

            
loadTablePrimaryKey() protected abstract method

Loads a primary key for the given table.

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

Table name.

return yii\db\Constraint|null

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

                abstract protected function loadTablePrimaryKey($tableName);

            
loadTableUniques() protected abstract method

Loads all unique constraints for the given table.

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

Table name.

return yii\db\Constraint[]

Unique constraints for the given table.

                abstract protected function loadTableUniques($tableName);