Propel 2 API
Class

Propel\Generator\Model\ForeignKey

class ForeignKey extends MappingModel

A class for information about table foreign keys.

Constants

NONE

These constants are the uppercase equivalents of the onDelete / onUpdate values in the schema definition.

NOACTION

CASCADE

RESTRICT

SETDEFAULT

SETNULL

Methods

__construct(string $name = null)

Constructs a new ForeignKey object.

loadMapping(array $attributes)

Loads a mapping definition from an array.

from MappingModel
array getAttributes()

Returns all definition attributes.

from MappingModel
mixed getAttribute(string $name, mixed $default = null)

Returns a particular attribute by a case-insensitive name.

from MappingModel
appendXml(DOMNode $node)

Appends DOM elements to represent this object in XML.

VendorInfo addVendorInfo(VendorInfo|array $vendor)

Adds a new VendorInfo instance to this current model object.

from MappingModel
VendorInfo getVendorInfoForType(string $type)

Returns a VendorInfo object by its type.

from MappingModel
string getConfiguredBehavior(string $behavior)

Returns the best class name for a given behavior.

from MappingModel
string toString()

String representation of the current object.

from MappingModel
string __toString()

String representation of the current object.

from MappingModel
string normalizeFKey(string $behavior)

Returns the normalized input of onDelete and onUpdate behaviors.

boolean hasOnUpdate()

Returns whether or not the onUpdate behavior is set.

boolean hasOnDelete()

Returns whether or not the onDelete behavior is set.

string getOnUpdate()

Returns the onUpdate behavior.

string getOnDelete()

Returns the onDelete behavior.

setOnDelete(string $behavior)

Sets the onDelete behavior.

setOnUpdate(string $behavior)

Sets the onUpdate behavior.

string getName()

Returns the foreign key name.

setName(string $name)

Sets the foreign key name.

string getPhpName()

Returns the phpName for this foreign key (if any).

setPhpName(string $name)

Sets a phpName to use for this foreign key.

string getRefPhpName()

Returns the refPhpName for this foreign key (if any).

setRefPhpName(string $name)

Sets a refPhpName to use for this foreign key.

string getDefaultJoin()

Returns the default join strategy for this foreign key (if any).

setDefaultJoin(string $join)

Sets the default join strategy for this foreign key (if any).

string getForeignTableName()

Returns the foreign table name of the FK.

string getForeignTableCommonName()

Returns the foreign table name without schema.

setForeignTableCommonName(string $tableName)

Sets the foreign table common name of the FK.

Table getForeignTable()

Returns the resolved foreign Table model object.

string getForeignSchemaName()

Returns the foreign schema name of the FK.

setForeignSchemaName(string $schemaName)

Set the foreign schema name of the foreign key.

setTable(Table $parent)

Sets the parent Table of the foreign key.

Table getTable()

Returns the parent Table of the foreign key.

string getTableName()

Returns the name of the table the foreign key is in.

string getSchemaName()

Returns the name of the schema the foreign key is in.

addReference(mixed $ref1, mixed $ref2 = null)

Adds a new reference entry to the foreign key.

clearReferences()

Clears the references of this foreign key.

array getLocalColumns()

Returns an array of local column names.

array getLocalColumnObjects()

Returns an array of local column objects.

string getLocalColumnName(integer $index)

Returns a local column name identified by a position.

Column getLocalColumn(integer $index)

Returns a local Column object identified by a position.

array getLocalForeignMapping()

Returns an array of local column to foreign column mapping for this foreign key.

array getForeignLocalMapping()

Returns an array of local column to foreign column mapping for this foreign key.

array getColumnObjectsMapping()

Returns an array of local and foreign column objects mapped for this foreign key.

string getMappedForeignColumn(string $local)

Returns the foreign column name mapped to a specified local column.

string getMappedLocalColumn(string $foreign)

Returns the local column name mapped to a specified foreign column.

array getForeignColumns()

Returns an array of foreign column names.

array getForeignColumnObjects()

Returns an array of foreign column objects.

string getForeignColumnName(integer $index)

Returns a foreign column name.

Column getForeignColumn($index)

Returns a foreign column object.

boolean isLocalColumnsRequired()

Returns whether this foreign key uses a required column, or a list of required columns.

boolean isForeignPrimaryKey()

Returns whether this foreign key is also the primary key of the foreign table.

boolean isComposite()

Returns whether or not this foreign key relies on more than one column binding.

boolean isLocalPrimaryKey()

Returns whether or not this foreign key is also the primary key of the local table.

setSkipSql(boolean $skip)

Sets whether or not this foreign key should have its creation SQL generated.

boolean isSkipSql()

Returns whether or not the SQL generation must be skipped for this foreign key.

boolean isMatchedByInverseFK()

Whether this foreign key is matched by an inverted foreign key (on foreign table).

getInverseFK()

array getOtherFks()

Returns the list of other foreign keys starting on the same table.

boolean isAtLeastOneForeignPrimaryKey()

Whether at least one foreign column is also the primary key of the foreign table.

array getForeignPrimaryKeys()

Returns all foreign columns which are also a primary key of the foreign table.

boolean isAtLeastOneLocalPrimaryKey()

Whether at least one local column is also a primary key.

Details

at line 54
public __construct(string $name = null)

Constructs a new ForeignKey object.

Parameters

string $name

in MappingModel at line 38
public loadMapping(array $attributes)

Loads a mapping definition from an array.

Parameters

array $attributes

in MappingModel at line 58
public array getAttributes()

Returns all definition attributes.

All attribute names (keys) are lowercase.

Return Value

array

in MappingModel at line 73
public mixed getAttribute(string $name, mixed $default = null)

Returns a particular attribute by a case-insensitive name.

If the attribute is not set, then the second default value is
returned instead.

Parameters

string $name
mixed $default

Return Value

mixed

at line 713
public appendXml(DOMNode $node)

Appends DOM elements to represent this object in XML.

Parameters

DOMNode $node

in MappingModel at line 138
public VendorInfo addVendorInfo(VendorInfo|array $vendor)

Adds a new VendorInfo instance to this current model object.

Parameters

VendorInfo|array $vendor

Return Value

VendorInfo

in MappingModel at line 158
public VendorInfo getVendorInfoForType(string $type)

Returns a VendorInfo object by its type.

Parameters

string $type

Return Value

VendorInfo

in MappingModel at line 176
public string getConfiguredBehavior(string $behavior)

Returns the best class name for a given behavior.

If not found, the method tries to autoload \Propel\Generator\Behavior\[Bname]\[Bname]Behavior

Parameters

string $behavior The behavior name (ie: timestampable)

Return Value

string $class The behavior fully qualified class name

Exceptions

BehaviorNotFoundException

in MappingModel at line 198
public string toString()

String representation of the current object.

Return Value

string

in MappingModel at line 213
public string __toString()

String representation of the current object.

Return Value

string

at line 93
public string normalizeFKey(string $behavior)

Returns the normalized input of onDelete and onUpdate behaviors.

Parameters

string $behavior

Return Value

string

at line 117
public boolean hasOnUpdate()

Returns whether or not the onUpdate behavior is set.

Return Value

boolean

at line 127
public boolean hasOnDelete()

Returns whether or not the onDelete behavior is set.

Return Value

boolean

at line 137
public string getOnUpdate()

Returns the onUpdate behavior.

Return Value

string

at line 147
public string getOnDelete()

Returns the onDelete behavior.

Return Value

string

at line 157
public setOnDelete(string $behavior)

Sets the onDelete behavior.

Parameters

string $behavior

at line 167
public setOnUpdate(string $behavior)

Sets the onUpdate behavior.

Parameters

string $behavior

at line 177
public string getName()

Returns the foreign key name.

Return Value

string

at line 187
public setName(string $name)

Sets the foreign key name.

Parameters

string $name

at line 197
public string getPhpName()

Returns the phpName for this foreign key (if any).

Return Value

string

at line 207
public setPhpName(string $name)

Sets a phpName to use for this foreign key.

Parameters

string $name

at line 217
public string getRefPhpName()

Returns the refPhpName for this foreign key (if any).

Return Value

string

at line 227
public setRefPhpName(string $name)

Sets a refPhpName to use for this foreign key.

Parameters

string $name

at line 237
public string getDefaultJoin()

Returns the default join strategy for this foreign key (if any).

Return Value

string

at line 247
public setDefaultJoin(string $join)

Sets the default join strategy for this foreign key (if any).

Parameters

string $join

at line 257
public string getForeignTableName()

Returns the foreign table name of the FK.

Return Value

string

at line 271
public string getForeignTableCommonName()

Returns the foreign table name without schema.

Return Value

string

at line 281
public setForeignTableCommonName(string $tableName)

Sets the foreign table common name of the FK.

Parameters

string $tableName

at line 291
public Table getForeignTable()

Returns the resolved foreign Table model object.

Return Value

Table

at line 301
public string getForeignSchemaName()

Returns the foreign schema name of the FK.

Return Value

string

at line 311
public setForeignSchemaName(string $schemaName)

Set the foreign schema name of the foreign key.

Parameters

string $schemaName

at line 321
public setTable(Table $parent)

Sets the parent Table of the foreign key.

Parameters

Table $parent

at line 331
public Table getTable()

Returns the parent Table of the foreign key.

Return Value

Table

at line 341
public string getTableName()

Returns the name of the table the foreign key is in.

Return Value

string

at line 351
public string getSchemaName()

Returns the name of the schema the foreign key is in.

Return Value

string

at line 362
public addReference(mixed $ref1, mixed $ref2 = null)

Adds a new reference entry to the foreign key.

Parameters

mixed $ref1 A Column object or an associative array or a string
mixed $ref2 A Column object or a single string name

at line 396
public clearReferences()

Clears the references of this foreign key.

at line 407
public array getLocalColumns()

Returns an array of local column names.

Return Value

array

at line 417
public array getLocalColumnObjects()

Returns an array of local column objects.

Return Value

array

at line 433
public string getLocalColumnName(integer $index)

Returns a local column name identified by a position.

Parameters

integer $index

Return Value

string

at line 444
public Column getLocalColumn(integer $index)

Returns a local Column object identified by a position.

Parameters

integer $index

Return Value

Column

at line 455
public array getLocalForeignMapping()

Returns an array of local column to foreign column mapping for this foreign key.

Return Value

array

at line 471
public array getForeignLocalMapping()

Returns an array of local column to foreign column mapping for this foreign key.

Return Value

array

at line 487
public array getColumnObjectsMapping()

Returns an array of local and foreign column objects mapped for this foreign key.

Return Value

array

at line 507
public string getMappedForeignColumn(string $local)

Returns the foreign column name mapped to a specified local column.

Parameters

string $local

Return Value

string

at line 520
public string getMappedLocalColumn(string $foreign)

Returns the local column name mapped to a specified foreign column.

Parameters

string $foreign

Return Value

string

at line 532
public array getForeignColumns()

Returns an array of foreign column names.

Return Value

array

at line 542
public array getForeignColumnObjects()

Returns an array of foreign column objects.

Return Value

array

at line 559
public string getForeignColumnName(integer $index)

Returns a foreign column name.

Parameters

integer $index

Return Value

string

at line 569
public Column getForeignColumn($index)

Returns a foreign column object.

Parameters

$index

Return Value

Column

at line 580
public boolean isLocalColumnsRequired()

Returns whether this foreign key uses a required column, or a list of required columns.

Return Value

boolean

at line 597
public boolean isForeignPrimaryKey()

Returns whether this foreign key is also the primary key of the foreign table.

Return Value

boolean Returns true if all columns inside this foreign key are primary keys of the foreign table

at line 623
public boolean isComposite()

Returns whether or not this foreign key relies on more than one column binding.

Return Value

boolean

at line 634
public boolean isLocalPrimaryKey()

Returns whether or not this foreign key is also the primary key of the local table.

Return Value

boolean True if all local columns are at the same time a primary key

at line 650
public setSkipSql(boolean $skip)

Sets whether or not this foreign key should have its creation SQL generated.

Parameters

boolean $skip

at line 661
public boolean isSkipSql()

Returns whether or not the SQL generation must be skipped for this foreign key.

Return Value

boolean

at line 676
public boolean isMatchedByInverseFK()

Whether this foreign key is matched by an inverted foreign key (on foreign table).

This is to prevent duplicate columns being generated for a 1:1 relationship that is represented
by foreign keys on both tables. I don't know if that's good practice ... but hell, why not
support it.

Return Value

boolean

at line 681
public getInverseFK()

at line 701
public array getOtherFks()

Returns the list of other foreign keys starting on the same table.

Used in many-to-many relationships.

Return Value

array

at line 761
public boolean isAtLeastOneForeignPrimaryKey()

Whether at least one foreign column is also the primary key of the foreign table.

Return Value

boolean True if there is at least one column that is a primary key of the foreign table

at line 773
public array getForeignPrimaryKeys()

Returns all foreign columns which are also a primary key of the foreign table.

Return Value

array Column[]

at line 799
public boolean isAtLeastOneLocalPrimaryKey()

Whether at least one local column is also a primary key.

Return Value

boolean True if there is at least one column that is a primary key