phpEZ v0.4.0

Foreign extends ObjAttribute
in package

Attribute to create a foreign key constraint on a field.

Specifies referential integrity constraints linking this field to another table's id.

Usage:

#[Foreign(User::class, DbThen::CASCADE, DbThen::CASCADE)]
public int $user_id;
Tags
see
Model::ddl()
Model::ddlDeps()
subpackage

db

Attributes
#[Attribute]
\Attribute::TARGET_PROPERTY

Table of Contents

Properties

$onDelete  : DbThen|null
$onUpdate  : DbThen|null
$target  : string

Methods

__construct()  : mixed
Initialize the foreign key attribute.
of()  : static|false
Extract an attribute instance from a reflected property.

Properties

$onDelete

public DbThen|null $onDelete = null

$onUpdate

public DbThen|null $onUpdate = null

$target

public string $target

Methods

__construct()

Initialize the foreign key attribute.

public __construct(string $target[, DbThen|null $onDelete = null ][, DbThen|null $onUpdate = null ][, DbThen $onWhatever = DbThen::NO_ACTION ]) : mixed
Parameters
$target : string

The target Model class that this field references.

$onDelete : DbThen|null = null

Action on referenced row delete. Defaults to $onWhatever.

$onUpdate : DbThen|null = null

Action on referenced row update. Defaults to $onWhatever.

$onWhatever : DbThen = DbThen::NO_ACTION

Default action for both if not specified separately. Default: NO_ACTION.

of()

Extract an attribute instance from a reflected property.

public static of(ReflectionProperty $field) : static|false

Searches the property's attributes for one matching this class name and instantiates it with the attribute's arguments.

Parameters
$field : ReflectionProperty

The property to inspect for attributes.

Return values
static|false

The attribute instance if found, false otherwise.

On this page

Search results