Documentation

ForeignKeyConstraint extends AbstractAsset
in package
implements Constraint

An abstraction class for a foreign key constraint.

Table of Contents

Interfaces

Constraint
Marker interface for constraints.

Properties

$_foreignColumnNames  : array<string|int, Identifier>
Asset identifier instances of the referenced table column names the foreign key constraint is associated with.
$_foreignTableName  : Table|Identifier
Table or asset identifier instance of the referenced table name the foreign key constraint is associated with.
$_localColumnNames  : array<string|int, Identifier>
Asset identifier instances of the referencing table column names the foreign key constraint is associated with.
$_localTable  : Table
Instance of the referencing table the foreign key constraint is associated with.
$_name  : string
$_namespace  : string|null
Namespace of the asset. If none isset the default namespace is assumed.
$_options  : array<string|int, mixed>
Options associated with the foreign key constraint.
$_quoted  : bool

Methods

__construct()  : mixed
Initializes the foreign key constraint.
getColumns()  : array<string|int, string>
Returns the names of the referencing table columns the constraint is associated with.
getForeignColumns()  : array<string|int, string>
Returns the names of the referenced table columns the foreign key constraint is associated with.
getForeignTableName()  : string
Returns the name of the referenced table the foreign key constraint is associated with.
getFullQualifiedName()  : string
The normalized name is full-qualified and lower-cased. Lower-casing is actually wrong, but we have to do it to keep our sanity. If you are using database objects that only differentiate in the casing (FOO vs Foo) then you will NOT be able to use Doctrine Schema abstraction.
getLocalColumns()  : array<string|int, string>
Returns the names of the referencing table columns the foreign key constraint is associated with.
getLocalTable()  : Table
getLocalTableName()  : string
Returns the name of the referencing table the foreign key constraint is associated with.
getName()  : string
Returns the name of this schema asset.
getNamespaceName()  : string|null
Gets the namespace name of this asset.
getOption()  : mixed
Returns an option associated with the foreign key constraint.
getOptions()  : array<string|int, mixed>
Returns the options associated with the foreign key constraint.
getQuotedColumns()  : array<string|int, string>
Returns the quoted representation of the referencing table column names the foreign key constraint is associated with.
getQuotedForeignColumns()  : array<string|int, string>
Returns the quoted representation of the referenced table column names the foreign key constraint is associated with.
getQuotedForeignTableName()  : string
Returns the quoted representation of the referenced table name the foreign key constraint is associated with.
getQuotedLocalColumns()  : array<string|int, string>
Returns the quoted representation of the referencing table column names the foreign key constraint is associated with.
getQuotedName()  : string
Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.
getShortestName()  : string
The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.
getUnqualifiedForeignTableName()  : string
Returns the non-schema qualified foreign table name.
getUnquotedForeignColumns()  : array<string|int, string>
Returns unquoted representation of foreign table column names for comparison with other FK
getUnquotedLocalColumns()  : array<string|int, string>
Returns unquoted representation of local table column names for comparison with other FK
hasOption()  : bool
Returns whether or not a given option is associated with the foreign key constraint.
intersectsIndexColumns()  : bool
Checks whether this foreign key constraint intersects the given index columns.
isInDefaultNamespace()  : bool
Is this asset in the default namespace?
isQuoted()  : bool
Checks if this asset's name is quoted.
onDelete()  : string|null
Returns the referential action for DELETE operations on the referenced table the foreign key constraint is associated with.
onUpdate()  : string|null
Returns the referential action for UPDATE operations on the referenced table the foreign key constraint is associated with.
setLocalTable()  : void
Sets the Table instance of the referencing table the foreign key constraint is associated with.
_generateIdentifierName()  : string
Generates an identifier from a list of column names obeying a certain string length.
_setName()  : void
Sets the name of this asset.
isIdentifierQuoted()  : bool
Checks if this identifier is quoted.
trimQuotes()  : string
Trim quotes from the identifier.
createIdentifierMap()  : array<string|int, Identifier>
onEvent()  : string|null
Returns the referential action for a given database operation on the referenced table the foreign key constraint is associated with.

Properties

$_foreignColumnNames

Asset identifier instances of the referenced table column names the foreign key constraint is associated with.

protected array<string|int, Identifier> $_foreignColumnNames

array($columnName => Identifier)

$_foreignTableName

Table or asset identifier instance of the referenced table name the foreign key constraint is associated with.

protected Table|Identifier $_foreignTableName

$_localColumnNames

Asset identifier instances of the referencing table column names the foreign key constraint is associated with.

protected array<string|int, Identifier> $_localColumnNames

array($columnName => Identifier)

$_localTable

Instance of the referencing table the foreign key constraint is associated with.

protected Table $_localTable

$_namespace

Namespace of the asset. If none isset the default namespace is assumed.

protected string|null $_namespace

$_options

Options associated with the foreign key constraint.

protected array<string|int, mixed> $_options

Methods

__construct()

Initializes the foreign key constraint.

public __construct(array<string|int, string> $localColumnNames, Table|string $foreignTableName, array<string|int, string> $foreignColumnNames[, string|null $name = null ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$localColumnNames : array<string|int, string>

Names of the referencing table columns.

$foreignTableName : Table|string

Referenced table.

$foreignColumnNames : array<string|int, string>

Names of the referenced table columns.

$name : string|null = null

Name of the foreign key constraint.

$options : array<string|int, mixed> = []

Options associated with the foreign key constraint.

getColumns()

Returns the names of the referencing table columns the constraint is associated with.

public getColumns() : array<string|int, string>
Tags
deprecated

Use getLocalColumns() instead.

see
getLocalColumns
Return values
array<string|int, string>

getForeignColumns()

Returns the names of the referenced table columns the foreign key constraint is associated with.

public getForeignColumns() : array<string|int, string>
Return values
array<string|int, string>

getForeignTableName()

Returns the name of the referenced table the foreign key constraint is associated with.

public getForeignTableName() : string
Return values
string

getFullQualifiedName()

The normalized name is full-qualified and lower-cased. Lower-casing is actually wrong, but we have to do it to keep our sanity. If you are using database objects that only differentiate in the casing (FOO vs Foo) then you will NOT be able to use Doctrine Schema abstraction.

public getFullQualifiedName(string $defaultNamespaceName) : string

Every non-namespaced element is prefixed with the default namespace name which is passed as argument to this method.

Parameters
$defaultNamespaceName : string
Tags
deprecated

Use getNamespaceName() and getName() instead.

Return values
string

getLocalColumns()

Returns the names of the referencing table columns the foreign key constraint is associated with.

public getLocalColumns() : array<string|int, string>
Return values
array<string|int, string>

getLocalTableName()

Returns the name of the referencing table the foreign key constraint is associated with.

public getLocalTableName() : string
Tags
deprecated

Use the table that contains the foreign key as part of its Table::$_fkConstraints instead.

Return values
string

getName()

Returns the name of this schema asset.

public getName() : string
Return values
string

getNamespaceName()

Gets the namespace name of this asset.

public getNamespaceName() : string|null

If NULL is returned this means the default namespace is used.

Return values
string|null

getOption()

Returns an option associated with the foreign key constraint.

public getOption(string $name) : mixed
Parameters
$name : string

Name of the option the foreign key constraint is associated with.

getOptions()

Returns the options associated with the foreign key constraint.

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getQuotedColumns()

Returns the quoted representation of the referencing table column names the foreign key constraint is associated with.

public getQuotedColumns(AbstractPlatform $platform) : array<string|int, string>

But only if they were defined with one or the referencing table column name is a keyword reserved by the platform. Otherwise the plain unquoted value as inserted is returned.

Parameters
$platform : AbstractPlatform

The platform to use for quotation.

Tags
deprecated

Use getQuotedLocalColumns() instead.

see
getQuotedLocalColumns
Return values
array<string|int, string>

getQuotedForeignColumns()

Returns the quoted representation of the referenced table column names the foreign key constraint is associated with.

public getQuotedForeignColumns(AbstractPlatform $platform) : array<string|int, string>

But only if they were defined with one or the referenced table column name is a keyword reserved by the platform. Otherwise the plain unquoted value as inserted is returned.

Parameters
$platform : AbstractPlatform

The platform to use for quotation.

Return values
array<string|int, string>

getQuotedForeignTableName()

Returns the quoted representation of the referenced table name the foreign key constraint is associated with.

public getQuotedForeignTableName(AbstractPlatform $platform) : string

But only if it was defined with one or the referenced table name is a keyword reserved by the platform. Otherwise the plain unquoted value as inserted is returned.

Parameters
$platform : AbstractPlatform

The platform to use for quotation.

Return values
string

getQuotedLocalColumns()

Returns the quoted representation of the referencing table column names the foreign key constraint is associated with.

public getQuotedLocalColumns(AbstractPlatform $platform) : array<string|int, string>

But only if they were defined with one or the referencing table column name is a keyword reserved by the platform. Otherwise the plain unquoted value as inserted is returned.

Parameters
$platform : AbstractPlatform

The platform to use for quotation.

Return values
array<string|int, string>

getQuotedName()

Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.

public getQuotedName(AbstractPlatform $platform) : string
Parameters
$platform : AbstractPlatform
Return values
string

getShortestName()

The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.

public getShortestName(string|null $defaultNamespaceName) : string
Parameters
$defaultNamespaceName : string|null
Return values
string

getUnqualifiedForeignTableName()

Returns the non-schema qualified foreign table name.

public getUnqualifiedForeignTableName() : string
Return values
string

getUnquotedForeignColumns()

Returns unquoted representation of foreign table column names for comparison with other FK

public getUnquotedForeignColumns() : array<string|int, string>
Return values
array<string|int, string>

getUnquotedLocalColumns()

Returns unquoted representation of local table column names for comparison with other FK

public getUnquotedLocalColumns() : array<string|int, string>
Return values
array<string|int, string>

hasOption()

Returns whether or not a given option is associated with the foreign key constraint.

public hasOption(string $name) : bool
Parameters
$name : string

Name of the option to check.

Return values
bool

intersectsIndexColumns()

Checks whether this foreign key constraint intersects the given index columns.

public intersectsIndexColumns(Index $index) : bool

Returns true if at least one of this foreign key's local columns matches one of the given index's columns, false otherwise.

Parameters
$index : Index

The index to be checked against.

Return values
bool

isInDefaultNamespace()

Is this asset in the default namespace?

public isInDefaultNamespace(string $defaultNamespaceName) : bool
Parameters
$defaultNamespaceName : string
Return values
bool

isQuoted()

Checks if this asset's name is quoted.

public isQuoted() : bool
Return values
bool

onDelete()

Returns the referential action for DELETE operations on the referenced table the foreign key constraint is associated with.

public onDelete() : string|null
Return values
string|null

onUpdate()

Returns the referential action for UPDATE operations on the referenced table the foreign key constraint is associated with.

public onUpdate() : string|null
Return values
string|null

setLocalTable()

Sets the Table instance of the referencing table the foreign key constraint is associated with.

public setLocalTable(Table $table) : void
Parameters
$table : Table

Instance of the referencing table.

Tags
deprecated

Use the table that contains the foreign key as part of its Table::$_fkConstraints instead.

_generateIdentifierName()

Generates an identifier from a list of column names obeying a certain string length.

protected _generateIdentifierName(array<string|int, string> $columnNames[, string $prefix = '' ][, int $maxSize = 30 ]) : string

This is especially important for Oracle, since it does not allow identifiers larger than 30 chars, however building idents automatically for foreign keys, composite keys or such can easily create very long names.

Parameters
$columnNames : array<string|int, string>
$prefix : string = ''
$maxSize : int = 30
Return values
string

_setName()

Sets the name of this asset.

protected _setName(string $name) : void
Parameters
$name : string

isIdentifierQuoted()

Checks if this identifier is quoted.

protected isIdentifierQuoted(string $identifier) : bool
Parameters
$identifier : string
Return values
bool

trimQuotes()

Trim quotes from the identifier.

protected trimQuotes(string $identifier) : string
Parameters
$identifier : string
Return values
string

createIdentifierMap()

private createIdentifierMap(array<string|int, string> $names) : array<string|int, Identifier>
Parameters
$names : array<string|int, string>
Return values
array<string|int, Identifier>

onEvent()

Returns the referential action for a given database operation on the referenced table the foreign key constraint is associated with.

private onEvent(string $event) : string|null
Parameters
$event : string

Name of the database operation/event to return the referential action for.

Return values
string|null

        
On this page

Search results