Class

ForeignKey

class ForeignKey extends XMLElement

A Class for information about foreign keys of a table.

Constants

NONE

NOACTION

CASCADE

RESTRICT

SETDEFAULT

SETNULL

Methods

loadFromXML(array $attributes)

This is the entry point method for loading data from XML.

from XMLElement
array getAttributes()

Returns the assoc array of attributes.

from XMLElement
mixed getAttribute(string $name, mixed $defaultValue = null)

Gets a particular attribute by [case-insensitive] name.

from XMLElement
appendXml(DOMNode $node)

VendorInfo addVendorInfo(mixed $data)

Sets an associated VendorInfo object.

from XMLElement
VendorInfo getVendorInfoForType($type)

Gets the any associated VendorInfo object.

from XMLElement
string getConfiguredBehavior(string $bname)

Find the best class name for a given behavior Looks in build.properties for path like propel.behavior.[bname].class If not found, tries to autoload [Bname]Behavior If no success, returns 'Behavior'

from XMLElement
toString()

String representation of the current object.

from XMLElement
__toString()

Magic string method

from XMLElement
__construct(string $name = null)

Constructs a new ForeignKey object.

normalizeFKey($attrib)

normalizes the input of onDelete, onUpdate attributes

hasOnUpdate()

returns whether or not the onUpdate attribute is set

hasOnDelete()

returns whether or not the onDelete attribute is set

string getOnUpdate()

returns the onUpdate attribute

string getOnDelete()

Returns the onDelete attribute

setOnDelete($value)

sets the onDelete attribute

setOnUpdate($value)

sets the onUpdate attribute

getName()

Returns the name attribute.

setName($name)

Sets the name attribute.

string getPhpName()

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

setPhpName(string $name)

Sets a phpName to use for this foreign key.

string getRefPhpName()

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

setRefPhpName(string $name)

Sets a refPhpName to use for this foreign key.

string getDefaultJoin()

Gets the defaultJoin for this foreign key (if any).

setDefaultJoin($defaultJoin)

Sets a defaultJoin to use for this foreign key.

string getForeignTableName()

Get the foreignTableName of the FK

string getForeignTableCommonName()

Get the foreign table name without schema

setForeignTableCommonName($tableName)

Set the foreignTableCommonName of the FK

Table getForeignTable()

Gets the resolved foreign Table model object.

getForeignSchemaName()

Get the foreignSchemaName of the FK

setForeignSchemaName($schemaName)

Set the foreignSchemaName of the FK

setTable(Table $parent)

Set the parent Table of the foreign key

getTable()

Get the parent Table of the foreign key

getTableName()

Returns the Name of the table the foreign key is in

getSchemaName()

Returns the Name of the schema the foreign key is in

addReference($p1, $p2 = null)

Adds a new reference entry to the foreign key.

clearReferences()

Clear the references of this foreign key

getLocalColumnNames()

Return a comma delimited string of local column names

getForeignColumnNames()

Return a comma delimited string of foreign column names

array getLocalColumns()

Return an array of local column names.

array getLocalColumnObjects()

Return an array of local column objects.

string getLocalColumnName($index)

Return a local column name.

Column getLocalColumn($index)

Return a local column object.

getLocalForeignMapping()

Utility method to get local column to foreign column mapping for this foreign key.

getForeignLocalMapping()

Utility method to get local column to foreign column mapping for this foreign key.

getColumnObjectsMapping()

Utility method to get local and foreign column objects mapping for this foreign key.

string getMappedForeignColumn($local)

Get the foreign column mapped to specified local column.

string getMappedLocalColumn($foreign)

Get the local column mapped to specified foreign column.

array getForeignColumns()

Return an array of foreign column names.

array getForeignColumnObjects()

Return an array of foreign column objects.

string getForeignColumnName($index)

Return a foreign column name.

Column getForeignColumn($index)

Return a foreign column object.

boolean isLocalColumnsRequired()

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

boolean isForeignPrimaryKey()

Whether this foreign key is also the primary key of the foreign 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 isComposite()

Whether this foreign key relies on more than one column binding

boolean isLocalPrimaryKey()

Whether this foreign key is also the primary key of the local table.

boolean isAtLeastOneLocalPrimaryKey()

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

setSkipSql(boolean $v)

Set whether this foreign key should have its creation sql generated.

boolean isSkipSql()

Skip generating sql for this foreign key.

boolean isMatchedByInverseFK()

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

getInverseFK()

ForeignKey getOtherFks()

Get the other foreign keys starting on the same table Used in many-to-many relationships

Details

in XMLElement at line 48
public loadFromXML(array $attributes)

This is the entry point method for loading data from XML.

It calls a setupObject() method that must be implemented by the child class.

Parameters

array $attributes The attributes for the XML tag.

in XMLElement at line 60
public array getAttributes()

Returns the assoc array of attributes.

All attribute names (keys) are lowercase.

Return Value

array

in XMLElement at line 74
public mixed getAttribute(string $name, mixed $defaultValue = null)

Gets a particular attribute by [case-insensitive] name.

If attribute is not set then the $defaultValue is returned.

Parameters

string $name The [case-insensitive] name of the attribute to lookup.
mixed $defaultValue The default value to use in case the attribute is not set.

Return Value

mixed The value of the attribute or $defaultValue if not set.

at line 768
public appendXml(DOMNode $node)

Parameters

DOMNode $node

See also

XMLElement::appendXml(DOMNode)

in XMLElement at line 134
public VendorInfo addVendorInfo(mixed $data)

Sets an associated VendorInfo object.

Parameters

mixed $data VendorInfo object or XML attrib data (array)

Return Value

VendorInfo

in XMLElement at line 154
public VendorInfo getVendorInfoForType($type)

Gets the any associated VendorInfo object.

Parameters

$type

Return Value

VendorInfo

in XMLElement at line 176
public string getConfiguredBehavior(string $bname)

Find the best class name for a given behavior Looks in build.properties for path like propel.behavior.[bname].class If not found, tries to autoload [Bname]Behavior If no success, returns 'Behavior'

Parameters

string $bname behavior name, e.g. 'timestampable'

Return Value

string behavior class name, e.g. 'TimestampableBehavior'

Exceptions

InvalidArgumentException

in XMLElement at line 199
public toString()

String representation of the current object.

This is an xml representation with the XML declaration removed.

See also

appendXml()

in XMLElement at line 214
public __toString()

Magic string method

See also

toString()

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

Constructs a new ForeignKey object.

Parameters

string $name

at line 112
public normalizeFKey($attrib)

normalizes the input of onDelete, onUpdate attributes

Parameters

$attrib

at line 128
public hasOnUpdate()

returns whether or not the onUpdate attribute is set

at line 142
public hasOnDelete()

returns whether or not the onDelete attribute is set

at line 158
public string getOnUpdate()

returns the onUpdate attribute

Return Value

string

at line 168
public string getOnDelete()

Returns the onDelete attribute

Return Value

string

at line 176
public setOnDelete($value)

sets the onDelete attribute

Parameters

$value

at line 184
public setOnUpdate($value)

sets the onUpdate attribute

Parameters

$value

at line 192
public getName()

Returns the name attribute.

at line 200
public setName($name)

Sets the name attribute.

Parameters

$name

at line 210
public string getPhpName()

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

Return Value

string

at line 220
public setPhpName(string $name)

Sets a phpName to use for this foreign key.

Parameters

string $name

at line 230
public string getRefPhpName()

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

Return Value

string

at line 240
public setRefPhpName(string $name)

Sets a refPhpName to use for this foreign key.

Parameters

string $name

at line 250
public string getDefaultJoin()

Gets the defaultJoin for this foreign key (if any).

Return Value

string

at line 260
public setDefaultJoin($defaultJoin)

Sets a defaultJoin to use for this foreign key.

Parameters

$defaultJoin

at line 270
public string getForeignTableName()

Get the foreignTableName of the FK

Return Value

string foreign table qualified name

at line 284
public string getForeignTableCommonName()

Get the foreign table name without schema

Return Value

string foreign table common name

at line 292
public setForeignTableCommonName($tableName)

Set the foreignTableCommonName of the FK

Parameters

$tableName

at line 302
public Table getForeignTable()

Gets the resolved foreign Table model object.

Return Value

Table

at line 310
public getForeignSchemaName()

Get the foreignSchemaName of the FK

at line 318
public setForeignSchemaName($schemaName)

Set the foreignSchemaName of the FK

Parameters

$schemaName

at line 326
public setTable(Table $parent)

Set the parent Table of the foreign key

Parameters

Table $parent

at line 334
public getTable()

Get the parent Table of the foreign key

at line 342
public getTableName()

Returns the Name of the table the foreign key is in

at line 350
public getSchemaName()

Returns the Name of the schema the foreign key is in

at line 358
public addReference($p1, $p2 = null)

Adds a new reference entry to the foreign key.

Parameters

$p1
$p2

at line 377
public clearReferences()

Clear the references of this foreign key

at line 388
public getLocalColumnNames()

Return a comma delimited string of local column names

at line 398
public getForeignColumnNames()

Return a comma delimited string of foreign column names

at line 408
public array getLocalColumns()

Return an array of local column names.

Return Value

array string[]

at line 418
public array getLocalColumnObjects()

Return an array of local column objects.

Return Value

array Column[]

at line 434
public string getLocalColumnName($index)

Return a local column name.

Parameters

$index

Return Value

string

at line 444
public Column getLocalColumn($index)

Return a local column object.

Parameters

$index

Return Value

Column

at line 453
public getLocalForeignMapping()

Utility method to get local column to foreign column mapping for this foreign key.

at line 467
public getForeignLocalMapping()

Utility method to get local column to foreign column mapping for this foreign key.

at line 481
public getColumnObjectsMapping()

Utility method to get local and foreign column objects mapping for this foreign key.

at line 501
public string getMappedForeignColumn($local)

Get the foreign column mapped to specified local column.

Parameters

$local

Return Value

string Column name.

at line 516
public string getMappedLocalColumn($foreign)

Get the local column mapped to specified foreign column.

Parameters

$foreign

Return Value

string Column name.

at line 531
public array getForeignColumns()

Return an array of foreign column names.

Return Value

array string[]

at line 541
public array getForeignColumnObjects()

Return an array of foreign column objects.

Return Value

array Column[]

at line 557
public string getForeignColumnName($index)

Return a foreign column name.

Parameters

$index

Return Value

string

at line 567
public Column getForeignColumn($index)

Return a foreign column object.

Parameters

$index

Return Value

Column

at line 577
public boolean isLocalColumnsRequired()

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

Return Value

boolean

at line 593
public boolean isForeignPrimaryKey()

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 616
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 628
public array getForeignPrimaryKeys()

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

Return Value

array Column[]

at line 654
public Boolean isComposite()

Whether this foreign key relies on more than one column binding

Return Value

Boolean

at line 664
public boolean isLocalPrimaryKey()

Whether 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 683
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

at line 701
public setSkipSql(boolean $v)

Set whether this foreign key should have its creation sql generated.

Parameters

boolean $v Value to assign to skipSql.

at line 711
public boolean isSkipSql()

Skip generating sql for this foreign key.

Return Value

boolean Value of skipSql.

at line 728
public boolean isMatchedByInverseFK()

Whether this foreign key is matched by an inverse 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 733
public getInverseFK()

at line 753
public ForeignKey getOtherFks()

Get the other foreign keys starting on the same table Used in many-to-many relationships

Return Value

ForeignKey