ForeignKey
extends ConstraintKey
in package
Class ForeignKey.
Tags
Table of Contents
- OPT_CASCADE = 'CASCADE'
- The change is allowed and propagates on the child table.
- OPT_NO_ACTION = 'NO ACTION'
- Synonym for RESTRICT.
- OPT_RESTRICT = 'RESTRICT'
- The change on the parent table is prevented.
- OPT_SET_NULL = 'SET NULL'
- The change is allowed, and the child row's foreign key columns are set to NULL.
- $columns : array<string|int, mixed>
- $constraint : string|null
- $database : Database
- $name : string|null
- $onDelete : string|null
- $onUpdate : string|null
- $referenceColumns : array<string|int, mixed>
- $referenceTable : string|null
- $type : string
- __call() : mixed
- __construct() : mixed
- constraint() : static
- onDelete() : static
- onUpdate() : static
- references() : static
- renderColumns() : string
- renderConstraint() : string|null
- renderName() : string|null
- renderOnDelete() : string|null
- renderOnUpdate() : string|null
- renderReferences() : string
- renderType() : string
- renderTypeAttributes() : string|null
- sql() : string
- makeReferenceOption() : string
Constants
OPT_CASCADE
The change is allowed and propagates on the child table.
public
string
OPT_CASCADE
= 'CASCADE'
For example, if a parent row is deleted, the child row is also deleted; if a parent row's ID changes, the child row's ID will also change.
OPT_NO_ACTION
Synonym for RESTRICT.
public
string
OPT_NO_ACTION
= 'NO ACTION'
Tags
OPT_RESTRICT
The change on the parent table is prevented.
public
string
OPT_RESTRICT
= 'RESTRICT'
The statement terminates with a 1451 error (SQLSTATE '2300'). This is the default behavior for both ON DELETE and ON UPDATE.
OPT_SET_NULL
The change is allowed, and the child row's foreign key columns are set to NULL.
public
string
OPT_SET_NULL
= 'SET NULL'
Properties
$columns
protected
array<string|int, mixed>
$columns
$constraint
protected
string|null
$constraint
= null
$database
protected
Database
$database
$name
protected
string|null
$name
$onDelete
protected
string|null
$onDelete
= null
$onUpdate
protected
string|null
$onUpdate
= null
$referenceColumns
protected
array<string|int, mixed>
$referenceColumns
= []
$referenceTable
protected
string|null
$referenceTable
= null
$type
protected
string
$type
= 'FOREIGN KEY'
Methods
__call()
public
__call(string $method, array<int, mixed> $arguments) : mixed
Parameters
- $method : string
- $arguments : array<int, mixed>
Return values
mixed —__construct()
public
__construct(Database $database, string|null $name, string $column, string ...$columns) : mixed
Parameters
- $database : Database
- $name : string|null
- $column : string
- $columns : string
Return values
mixed —constraint()
public
constraint(string $name) : static
Parameters
- $name : string
Return values
static —onDelete()
public
onDelete(string $option) : static
Parameters
- $option : string
Return values
static —onUpdate()
public
onUpdate(string $option) : static
Parameters
- $option : string
Return values
static —references()
public
references(string $table, string $column, string ...$columns) : static
Parameters
- $table : string
- $column : string
- $columns : string
Return values
static —renderColumns()
protected
renderColumns() : string
Return values
string —renderConstraint()
protected
renderConstraint() : string|null
Return values
string|null —renderName()
protected
renderName() : string|null
Return values
string|null —renderOnDelete()
protected
renderOnDelete() : string|null
Return values
string|null —renderOnUpdate()
protected
renderOnUpdate() : string|null
Return values
string|null —renderReferences()
protected
renderReferences() : string
Return values
string —renderType()
protected
renderType() : string
Return values
string —renderTypeAttributes()
protected
renderTypeAttributes() : string|null
Return values
string|null —sql()
protected
abstract sql() : string
Return values
string —makeReferenceOption()
private
makeReferenceOption(string $option) : string
Parameters
- $option : string