Constraint
Less than 1 minute
Constraint
Provides SQL constraint management helpers for DBI drivers.
trait ConstraintThis trait includes functionality to list, create, and remove table constraints such as foreign keys and other schema-level rules.
Methods
listConstraints
Retrieves a list of constraints for a given table or all tables in the schema.
public listConstraints(?string $table, ?string $type, bool $invertType, false $): voidParameters
| Parameter | Type | Description |
|---|---|---|
$table | string | The name of the table. If null, constraints for all tables in the schema will be retrieved. |
$type | string | The type of constraints to retrieve. If null, all types of constraints will be retrieved. |
$invertType | bool | Whether to invert the constraint type filter. If true, constraints of types other than the specified type will be retrieved. |
$ | false |
addConstraint
Adds a constraint to a table in the database.
public addConstraint(string $constraintName, array $info): boolParameters
| Parameter | Type | Description |
|---|---|---|
$constraintName | string | the name of the constraint to add |
$info | array |
dropConstraint
Drops a constraint from a table.
public dropConstraint(string $constraintName, string $tableName, bool $ifExists, bool $cascade): boolParameters
| Parameter | Type | Description |
|---|---|---|
$constraintName | string | the name of the constraint to drop |
$tableName | string | the table containing the constraint |
$ifExists | bool | when true, includes IF EXISTS clauses for table and constraint |
$cascade | bool | when true, appends CASCADE to also drop dependent objects |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000