0 follower

Final Class Yiisoft\Db\Constraint\ForeignKey

InheritanceYiisoft\Db\Constraint\ForeignKey

Represents a foreign key constraint in a database.

A foreign key constraint is a constraint that enforces referential integrity between two tables.

It has information about the table and column(s) that the constraint applies to, as well as any actions that should be taken when a referenced record is deleted or updated.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Db\Constraint\ForeignKey

Property Details

Hide inherited properties

$columnNames public property
public array $columnNames = []
$foreignColumnNames public property
$foreignSchemaName public property
$foreignTableName public property
$name public property
public string $name ''
$onDelete public property
public string|null $onDelete null
$onUpdate public property
public string|null $onUpdate null

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string $name '', string[] $columnNames = [], string $foreignSchemaName '', string $foreignTableName '', string[] $foreignColumnNames = [], string|null $onDelete null, string|null $onUpdate null )
$name string

The constraint name.

$columnNames string[]

The list of column names the constraint belongs to.

$foreignSchemaName string

The referenced schema name.

$foreignTableName string

The referenced table name.

$foreignColumnNames string[]

The list of referenced table column names.

$onDelete string|null

The referential action if rows in a referenced table are to be deleted.

$onUpdate string|null

The referential action if rows in a referenced table are to be updated.

                public function __construct(
    public readonly string $name = '',
    public readonly array $columnNames = [],
    public readonly string $foreignSchemaName = '',
    public readonly string $foreignTableName = '',
    public readonly array $foreignColumnNames = [],
    public readonly ?string $onDelete = null,
    public readonly ?string $onUpdate = null,
) {}