class ForeignKeyConstraint extends AbstractAsset implements Constraint (View source)

An abstraction class for a foreign key constraint.

Properties

protected string $_name from AbstractAsset
protected string|null $_namespace Namespace of the asset. If none isset the default namespace is assumed. from AbstractAsset
protected bool $_quoted from AbstractAsset
protected Table $_localTable Instance of the referencing table the foreign key constraint is associated with.
protected Identifier[] $_localColumnNames Asset identifier instances of the referencing table column names the foreign key constraint is associated with.
protected Table|Identifier $_foreignTableName Table or asset identifier instance of the referenced table name the foreign key constraint is associated with.
protected Identifier[] $_foreignColumnNames Asset identifier instances of the referenced table column names the foreign key constraint is associated with.
protected array $_options

Methods

void
_setName(string $name)

Sets the name of this asset.

bool
isInDefaultNamespace(string $defaultNamespaceName)

Is this asset in the default namespace?

string|null
getNamespaceName()

Gets the namespace name of this asset.

string
getShortestName(string $defaultNamespaceName)

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

string
getFullQualifiedName(string $defaultNamespaceName)

The normalized name is full-qualified and lowerspaced. Lowerspacing 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.

bool
isQuoted()

Checks if this asset's name is quoted.

bool
isIdentifierQuoted(string $identifier)

Checks if this identifier is quoted.

string
trimQuotes(string $identifier)

Trim quotes from the identifier.

string
getName()

Returns the name of this schema asset.

string
getQuotedName(AbstractPlatform $platform)

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

string
_generateIdentifierName(array $columnNames, string $prefix = '', int $maxSize = 30)

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

__construct(array $localColumnNames, Table|string $foreignTableName, array $foreignColumnNames, string|null $name = null, array $options = [])

Initializes the foreign key constraint.

string
getLocalTableName()

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

void
setLocalTable(Table $table)

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

getLocalTable()

No description

array
getLocalColumns()

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

array
getQuotedLocalColumns(AbstractPlatform $platform)

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

array
getUnquotedLocalColumns()

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

array
getUnquotedForeignColumns()

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

array
getColumns()

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

array
getQuotedColumns(AbstractPlatform $platform)

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

string
getForeignTableName()

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

string
getUnqualifiedForeignTableName()

Returns the non-schema qualified foreign table name.

string
getQuotedForeignTableName(AbstractPlatform $platform)

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

array
getForeignColumns()

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

array
getQuotedForeignColumns(AbstractPlatform $platform)

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

bool
hasOption(string $name)

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

mixed
getOption(string $name)

Returns an option associated with the foreign key constraint.

array
getOptions()

Returns the options associated with the foreign key constraint.

string|null
onUpdate()

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

string|null
onDelete()

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

bool
intersectsIndexColumns(Index $index)

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

Details

protected void _setName(string $name)

Sets the name of this asset.

Parameters

string $name

Return Value

void

bool isInDefaultNamespace(string $defaultNamespaceName)

Is this asset in the default namespace?

Parameters

string $defaultNamespaceName

Return Value

bool

string|null getNamespaceName()

Gets the namespace name of this asset.

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

Return Value

string|null

string getShortestName(string $defaultNamespaceName)

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

Parameters

string $defaultNamespaceName

Return Value

string

string getFullQualifiedName(string $defaultNamespaceName)

The normalized name is full-qualified and lowerspaced. Lowerspacing 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.

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

Parameters

string $defaultNamespaceName

Return Value

string

bool isQuoted()

Checks if this asset's name is quoted.

Return Value

bool

protected bool isIdentifierQuoted(string $identifier)

Checks if this identifier is quoted.

Parameters

string $identifier

Return Value

bool

protected string trimQuotes(string $identifier)

Trim quotes from the identifier.

Parameters

string $identifier

Return Value

string

string getName()

Returns the name of this schema asset.

Return Value

string

string getQuotedName(AbstractPlatform $platform)

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

Parameters

AbstractPlatform $platform

Return Value

string

protected string _generateIdentifierName(array $columnNames, string $prefix = '', int $maxSize = 30)

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

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

array $columnNames
string $prefix
int $maxSize

Return Value

string

__construct(array $localColumnNames, Table|string $foreignTableName, array $foreignColumnNames, string|null $name = null, array $options = [])

Initializes the foreign key constraint.

Parameters

array $localColumnNames Names of the referencing table columns.
Table|string $foreignTableName Referenced table.
array $foreignColumnNames Names of the referenced table columns.
string|null $name Name of the foreign key constraint.
array $options Options associated with the foreign key constraint.

string getLocalTableName()

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

Return Value

string

void setLocalTable(Table $table)

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

Parameters

Table $table Instance of the referencing table.

Return Value

void

Table getLocalTable()

Return Value

Table

array getLocalColumns()

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

Return Value

array

array getQuotedLocalColumns(AbstractPlatform $platform)

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

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

AbstractPlatform $platform The platform to use for quotation.

Return Value

array

array getUnquotedLocalColumns()

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

Return Value

array

array getUnquotedForeignColumns()

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

Return Value

array

array getColumns()

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

Return Value

array

See also

getLocalColumns

array getQuotedColumns(AbstractPlatform $platform)

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

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

AbstractPlatform $platform The platform to use for quotation.

Return Value

array

See also

getQuotedLocalColumns

string getForeignTableName()

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

Return Value

string

string getUnqualifiedForeignTableName()

Returns the non-schema qualified foreign table name.

Return Value

string

string getQuotedForeignTableName(AbstractPlatform $platform)

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

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

AbstractPlatform $platform The platform to use for quotation.

Return Value

string

array getForeignColumns()

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

Return Value

array

array getQuotedForeignColumns(AbstractPlatform $platform)

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

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

AbstractPlatform $platform The platform to use for quotation.

Return Value

array

bool hasOption(string $name)

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

Parameters

string $name Name of the option to check.

Return Value

bool

mixed getOption(string $name)

Returns an option associated with the foreign key constraint.

Parameters

string $name Name of the option the foreign key constraint is associated with.

Return Value

mixed

array getOptions()

Returns the options associated with the foreign key constraint.

Return Value

array

string|null onUpdate()

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

Return Value

string|null

string|null onDelete()

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

Return Value

string|null

bool intersectsIndexColumns(Index $index)

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

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 Value

bool