HumHub Documentation (unofficial)

ConstraintFinderTrait

ConstraintFinderTrait provides methods for getting a table constraint information.

Tags
author

Sergey Makinen sergey@makinen.ru

since
2.0.13

Table of Contents

Properties

$schemaChecks  : array<string|int, array<string|int, CheckConstraint>>
$schemaDefaultValues  : array<string|int, DefaultValueConstraint>
$schemaForeignKeys  : array<string|int, array<string|int, ForeignKeyConstraint>>
$schemaIndexes  : array<string|int, array<string|int, IndexConstraint>>
$schemaPrimaryKeys  : array<string|int, Constraint>
$schemaUniques  : array<string|int, array<string|int, IndexConstraint>>

Methods

getSchemaChecks()  : array<string|int, array<string|int, CheckConstraint>>
Returns check constraints for all tables in the database.
getSchemaDefaultValues()  : array<string|int, DefaultValueConstraint>
Returns default value constraints for all tables in the database.
getSchemaForeignKeys()  : array<string|int, array<string|int, ForeignKeyConstraint>>
Returns foreign keys for all tables in the database.
getSchemaIndexes()  : array<string|int, array<string|int, IndexConstraint>>
Returns indexes for all tables in the database.
getSchemaPrimaryKeys()  : array<string|int, Constraint>
Returns primary keys for all tables in the database.
getSchemaUniques()  : array<string|int, array<string|int, Constraint>>
Returns unique constraints for all tables in the database.
getTableChecks()  : array<string|int, CheckConstraint>
Obtains the check constraints information for the named table.
getTableDefaultValues()  : array<string|int, DefaultValueConstraint>
Obtains the default value constraints information for the named table.
getTableForeignKeys()  : array<string|int, ForeignKeyConstraint>
Obtains the foreign keys information for the named table.
getTableIndexes()  : array<string|int, IndexConstraint>
Obtains the indexes information for the named table.
getTablePrimaryKey()  : Constraint|null
Obtains the primary key for the named table.
getTableUniques()  : array<string|int, Constraint>
Obtains the unique constraints information for the named table.
getSchemaMetadata()  : array<string|int, mixed>
Returns the metadata of the given type for all tables in the given schema.
getTableMetadata()  : mixed
Returns the metadata of the given type for the given table.
loadTableChecks()  : array<string|int, CheckConstraint>
Loads all check constraints for the given table.
loadTableDefaultValues()  : array<string|int, DefaultValueConstraint>
Loads all default value constraints for the given table.
loadTableForeignKeys()  : array<string|int, ForeignKeyConstraint>
Loads all foreign keys for the given table.
loadTableIndexes()  : array<string|int, IndexConstraint>
Loads all indexes for the given table.
loadTablePrimaryKey()  : Constraint|null
Loads a primary key for the given table.
loadTableUniques()  : array<string|int, Constraint>
Loads all unique constraints for the given table.

Properties

$schemaChecks

public array<string|int, array<string|int, 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.

$schemaDefaultValues

public array<string|int, 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.

$schemaForeignKeys

public array<string|int, array<string|int, 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.

$schemaIndexes

public array<string|int, array<string|int, 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.

$schemaPrimaryKeys

public array<string|int, 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.

$schemaUniques

public array<string|int, array<string|int, 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.

Methods

getSchemaChecks()

Returns check constraints for all tables in the database.

public getSchemaChecks([string $schema = '' ][, bool $refresh = false ]) : array<string|int, array<string|int, CheckConstraint>>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, array<string|int, CheckConstraint>> —

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

getSchemaDefaultValues()

Returns default value constraints for all tables in the database.

public getSchemaDefaultValues([string $schema = '' ][, bool $refresh = false ]) : array<string|int, DefaultValueConstraint>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, DefaultValueConstraint> —

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

getSchemaForeignKeys()

Returns foreign keys for all tables in the database.

public getSchemaForeignKeys([string $schema = '' ][, bool $refresh = false ]) : array<string|int, array<string|int, ForeignKeyConstraint>>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, array<string|int, ForeignKeyConstraint>> —

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

getSchemaIndexes()

Returns indexes for all tables in the database.

public getSchemaIndexes([string $schema = '' ][, bool $refresh = false ]) : array<string|int, array<string|int, IndexConstraint>>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, array<string|int, IndexConstraint>> —

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

getSchemaPrimaryKeys()

Returns primary keys for all tables in the database.

public getSchemaPrimaryKeys([string $schema = '' ][, bool $refresh = false ]) : array<string|int, Constraint>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, Constraint> —

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

getSchemaUniques()

Returns unique constraints for all tables in the database.

public getSchemaUniques([string $schema = '' ][, bool $refresh = false ]) : array<string|int, array<string|int, Constraint>>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, array<string|int, Constraint>> —

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

getTableChecks()

Obtains the check constraints information for the named table.

public getTableChecks(string $name[, bool $refresh = false ]) : array<string|int, CheckConstraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, CheckConstraint> —

table check constraints.

getTableDefaultValues()

Obtains the default value constraints information for the named table.

public getTableDefaultValues(string $name[, bool $refresh = false ]) : array<string|int, DefaultValueConstraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, DefaultValueConstraint> —

table default value constraints.

getTableForeignKeys()

Obtains the foreign keys information for the named table.

public getTableForeignKeys(string $name[, bool $refresh = false ]) : array<string|int, ForeignKeyConstraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, ForeignKeyConstraint> —

table foreign keys.

getTableIndexes()

Obtains the indexes information for the named table.

public getTableIndexes(string $name[, bool $refresh = false ]) : array<string|int, IndexConstraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, IndexConstraint> —

table indexes.

getTablePrimaryKey()

Obtains the primary key for the named table.

public getTablePrimaryKey(string $name[, bool $refresh = false ]) : Constraint|null
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
Constraint|null —

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

getTableUniques()

Obtains the unique constraints information for the named table.

public getTableUniques(string $name[, bool $refresh = false ]) : array<string|int, Constraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, Constraint> —

table unique constraints.

getSchemaMetadata()

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

protected abstract getSchemaMetadata(string $schema, string $type, bool $refresh) : array<string|int, mixed>
Parameters
$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.

Return values
array<string|int, mixed> —

array of metadata.

getTableMetadata()

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

protected abstract getTableMetadata(string $name, string $type, bool $refresh) : mixed
Parameters
$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.

Return values
mixed —

metadata.

loadTableChecks()

Loads all check constraints for the given table.

protected abstract loadTableChecks(string $tableName) : array<string|int, CheckConstraint>
Parameters
$tableName : string

table name.

Return values
array<string|int, CheckConstraint> —

check constraints for the given table.

loadTableDefaultValues()

Loads all default value constraints for the given table.

protected abstract loadTableDefaultValues(string $tableName) : array<string|int, DefaultValueConstraint>
Parameters
$tableName : string

table name.

Return values
array<string|int, DefaultValueConstraint> —

default value constraints for the given table.

loadTableForeignKeys()

Loads all foreign keys for the given table.

protected abstract loadTableForeignKeys(string $tableName) : array<string|int, ForeignKeyConstraint>
Parameters
$tableName : string

table name.

Return values
array<string|int, ForeignKeyConstraint> —

foreign keys for the given table.

loadTableIndexes()

Loads all indexes for the given table.

protected abstract loadTableIndexes(string $tableName) : array<string|int, IndexConstraint>
Parameters
$tableName : string

table name.

Return values
array<string|int, IndexConstraint> —

indexes for the given table.

loadTablePrimaryKey()

Loads a primary key for the given table.

protected abstract loadTablePrimaryKey(string $tableName) : Constraint|null
Parameters
$tableName : string

table name.

Return values
Constraint|null —

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

loadTableUniques()

Loads all unique constraints for the given table.

protected abstract loadTableUniques(string $tableName) : array<string|int, Constraint>
Parameters
$tableName : string

table name.

Return values
array<string|int, Constraint> —

unique constraints for the given table.


        
On this page

Search results