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
$_name
protected
string
$_name
= ''
$_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
$_quoted
protected
bool
$_quoted
= false
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
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
stringgetFullQualifiedName()
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
Return values
stringgetLocalColumns()
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>getLocalTable()
public
getLocalTable() : Table
Tags
Return values
TablegetLocalTableName()
Returns the name of the referencing table the foreign key constraint is associated with.
public
getLocalTableName() : string
Tags
Return values
stringgetName()
Returns the name of this schema asset.
public
getName() : string
Return values
stringgetNamespaceName()
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|nullgetOption()
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
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
stringgetQuotedLocalColumns()
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
stringgetShortestName()
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
stringgetUnqualifiedForeignTableName()
Returns the non-schema qualified foreign table name.
public
getUnqualifiedForeignTableName() : string
Return values
stringgetUnquotedForeignColumns()
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
boolintersectsIndexColumns()
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
boolisInDefaultNamespace()
Is this asset in the default namespace?
public
isInDefaultNamespace(string $defaultNamespaceName) : bool
Parameters
- $defaultNamespaceName : string
Return values
boolisQuoted()
Checks if this asset's name is quoted.
public
isQuoted() : bool
Return values
boolonDelete()
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|nullonUpdate()
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|nullsetLocalTable()
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
_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
booltrimQuotes()
Trim quotes from the identifier.
protected
trimQuotes(string $identifier) : string
Parameters
- $identifier : string
Return values
stringcreateIdentifierMap()
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.