Propel 2 API
Class

Propel\Generator\Model\Table

class Table extends ScopedMappingModel implements IdMethod

Data about a table used in an application.

Methods

__construct(string $name = null)

Constructs a table object with a name

string getNamespace()

Returns the namespace.

from ScopedMappingModel
setNamespace(string $namespace)

Sets the namespace.

from ScopedMappingModel
boolean isAbsoluteNamespace(string $namespace)

Returns whether or not the namespace is absolute.

from ScopedMappingModel
string getPackage()

Returns the package name.

from ScopedMappingModel
setPackage(string $package)

Sets the package name.

from ScopedMappingModel
string getSchema()

Returns the schema name.

from ScopedMappingModel
setSchema(string $schema)

Sets the schema name.

from ScopedMappingModel
setupObject()

string getBuildProperty(string $key)

Returns a build property value for the database this table belongs to.

applyBehaviors()

Executes behavior table modifiers.

doFinalInitialization()

<p>A hook for the SAX XML parser to call when this table has been fully loaded from the XML, and all nested elements have been processed.</p>

addExtraIndices()

Adds extra indices for reverse foreign keys This is required for MySQL databases, and is called from Database::doFinalInitialization()

string getColumnList(array $columns, string $delimiter = ',')

Returns a delimiter-delimited string list of column names.

doNaming()

Names composing objects which haven't yet been named.

string getBaseClass()

Returns the name of the base class used for superclass of all objects of this table.

setBaseClass(string $class)

Sets the base class name.

Column addColumn(Column|array $col)

Adds a new column to the table.

removeColumn(Column|string $column)

Removes a column from the table.

adjustColumnPositions()

ForeignKey addForeignKey(ForeignKey|array $fkdata)

Adds a new foreign key to this table.

Column getChildrenColumn()

Returns the column that subclasses the class representing this table can be produced from.

array getChildrenNames()

Returns the subclasses that can be created from this table.

addReferrer(ForeignKey $fk)

Adds the foreign key from another table that refers to this table.

array getReferrers()

Returns the list of references to this table.

setupReferrers(boolean $throwErrors = false)

Browses the foreign keys and creates referrers for the foreign table.

array getCrossFks()

Returns the list of cross foreign keys.

boolean setContainsForeignPK($b)

Sets whether or not this table contains a foreign primary key.

boolean getContainsForeignPK()

Returns whether or not this table contains a foreign primary key.

array getForeignTableNames()

Returns the list of tables referenced by foreign keys in this table.

boolean requiresTransactionInPostgres()

Return true if the column requires a transaction in Postgres.

addIdMethodParameter(IdMethodParameter $idMethodParameter)

Adds a new parameter for the strategy that generates primary keys.

removeIndex(string $name)

Removes a index from the table.

bool hasIndex(string $name)

Checks if the table has a index by name.

Index addIndex(Index $index)

Adds a new index to the indices list and set the parent table of the column to the current table.

Unique addUnique(Unique $unique)

Adds a new Unique index to the list of unique indices and set the parent table of the column to the current table.

GeneratorConfig getGeneratorConfig()

Retrieves the configuration object, filled by build.properties

Behavior addBehavior($bdata)

Adds a new Behavior to the table.

array getBehaviors()

Returns the list of table behaviors.

boolean hasBehavior(string $name)

check if the table has a behavior by name

Behavior getBehavior(string $name)

Get one table behavior by name

boolean hasAdditionalBuilders()

Returns whether or not the table behaviors offer additional builders.

Array getEarlyBehaviors()

Get the early table behaviors

array getAdditionalBuilders()

Returns the list of additional builders provided by the table behaviors.

string getName()

Returns the full table name (including schema name when possible).

string getDescription()

Returns the table description.

boolean hasDescription()

Returns whether or not the table has a description.

setDescription(string $description)

Sets the table description.

string getPhpName()

Returns the name to use in PHP sources.

setPhpName(string $phpName)

Sets the name to use in PHP sources.

string getStudlyPhpName()

Returns the studly version of PHP name.

string getCommonName()

Returns the common name (without schema name).

setCommonName(string $name)

Sets the table common name (without schema name).

setDefaultStringFormat(string $format)

Sets the default string format for ActiveRecord objects in this table.

string getDefaultStringFormat()

Returns the default string format for ActiveRecord objects in this table, or the one for the whole database if not set.

string getIdMethod()

Returns the method strategy for generating primary keys.

boolean isAllowPkInsert()

Returns whether we allow to insert primary keys on tables with native id method.

setIdMethod(string $idMethod)

Sets the method strategy for generating primary keys.

boolean isSkipSql()

Returns whether or not Propel has to skip DDL SQL generation for this table (in the event it should not be created from scratch).

setSkipSql(boolean $skip)

Sets whether or not this table should have its SQL DDL code generated.

boolean isReadOnly()

Returns whether or not this table is read-only.

boolean isReloadOnInsert()

Whether to force object to reload on INSERT.

boolean isReloadOnUpdate()

Returns whether or not to force object to reload on UPDATE.

string getAlias()

Returns the PHP name of an active record object this entry references.

boolean isAlias()

Returns whether or not this table is specified in the schema or if there is just a foreign key reference to it.

setAlias(string $alias)

Sets whether or not this table is specified in the schema or if there is just a foreign key reference to it.

string getInterface()

Returns the interface objects of this table will implement.

setInterface(string $interface)

Sets the interface objects of this table will implement.

boolean isAbstract()

Returns whether or not a table is abstract, it marks the business object class that is generated as being abstract.

setAbstract(boolean $isAbstract)

Sets whether or not a table is abstract, it marks the business object class that is generated as being abstract.

Column[] getColumns()

Returns an array containing all Column objects in the table.

integer getNumColumns()

Returns the number of columns in this table.

integer getNumLazyLoadColumns()

Returns the number of lazy loaded columns in this table.

boolean hasEnumColumns()

Returns whether or not one of the columns is of type ENUM.

array getForeignKeys()

Returns the list of all foreign keys.

getIdMethodParameters()

Returns a Collection of parameters relevant for the chosen id generation method.

array getIndices()

Returns the list of all indices of this table.

array getUnices()

Returns the list of all unique indices of this table.

boolean hasColumn(Column|string $column, boolean $caseInsensitive = false)

Returns whether or not the table has a column.

Column getColumn(string $name, boolean $caseInsensitive = false)

Returns the Column object with the specified name.

Column getColumnByPhpName(string $phpName)

Returns a specified column by its php name.

array getForeignKeysReferencingTable(string $tableName)

Returns all foreign keys from this table that reference the table passed in argument.

array getColumnForeignKeys(string $column)

Returns the foreign keys that include column in it's list of local columns.

setDatabase(Database $database)

Set the database that contains this table.

Database getDatabase()

Get the database that contains this table.

PlatformInterface getPlatform()

Returns the Database platform.

boolean isForReferenceOnly()

Returns whether or not code and SQL must be created for this table.

setForReferenceOnly(boolean $v)

Returns whether or not to determine if code/sql gets created for this table.

appendXml(DOMNode $node)

Appends XML nodes to passed-in DOMNode.

Column[] getPrimaryKey()

Returns the collection of Columns which make up the single primary key for this table.

boolean hasPrimaryKey()

Returns whether or not this table has a primary key.

boolean hasCompositePrimaryKey()

Returns whether or not this table has a composite primary key.

Column getFirstPrimaryKeyColumn()

Returns the first primary key column.

boolean hasAutoIncrementPrimaryKey()

Returns whether or not this table has any auto-increment primary keys.

Column getAutoIncrementPrimaryKey()

Returns the auto incremented primary key.

boolean getIsCrossRef()

Returns whether or not there is a cross reference status for this foreign key.

boolean isCrossRef()

Alias for Table::getIsCrossRef.

setIsCrossRef(boolean $isCrossRef)

Sets a cross reference status for this foreign key.

boolean hasForeignKeys()

Returns whether or not the table has foreign keys.

boolean hasCrossForeignKeys()

Returns whether the table has cross foreign keys or not.

Details

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

Constructs a table object with a name

Parameters

string $name table name

in ScopedMappingModel at line 57
public string getNamespace()

Returns the namespace.

Return Value

string

in ScopedMappingModel at line 67
public setNamespace(string $namespace)

Sets the namespace.

Parameters

string $namespace

in ScopedMappingModel at line 90
public boolean isAbsoluteNamespace(string $namespace)

Returns whether or not the namespace is absolute.

A namespace is absolute if it starts with a "\".

Parameters

string $namespace

Return Value

boolean

in ScopedMappingModel at line 100
public string getPackage()

Returns the package name.

Return Value

string

in ScopedMappingModel at line 110
public setPackage(string $package)

Sets the package name.

Parameters

string $package

in ScopedMappingModel at line 125
public string getSchema()

Returns the schema name.

Return Value

string

in ScopedMappingModel at line 135
public setSchema(string $schema)

Sets the schema name.

Parameters

string $schema

at line 118
public setupObject()

at line 162
public string getBuildProperty(string $key)

Returns a build property value for the database this table belongs to.

Parameters

string $key

Return Value

string

at line 171
public applyBehaviors()

Executes behavior table modifiers.

at line 189
public doFinalInitialization()

<p>A hook for the SAX XML parser to call when this table has been fully loaded from the XML, and all nested elements have been processed.</p>

<p>Performs heavy indexing and naming of elements which weren't
provided with a name.</p>

at line 251
public addExtraIndices()

Adds extra indices for reverse foreign keys This is required for MySQL databases, and is called from Database::doFinalInitialization()

at line 361
public string getColumnList(array $columns, string $delimiter = ',')

Returns a delimiter-delimited string list of column names.

Parameters

array $columns
string $delimiter

Return Value

string

See also

Platform::getColumnList() if quoting is required

at line 378
public doNaming()

Names composing objects which haven't yet been named.

This
currently consists of foreign-key and index entities.

at line 438
public string getBaseClass()

Returns the name of the base class used for superclass of all objects of this table.

Return Value

string

at line 456
public setBaseClass(string $class)

Sets the base class name.

Parameters

string $class

at line 467
public Column addColumn(Column|array $col)

Adds a new column to the table.

Parameters

Column|array $col

Return Value

Column

at line 506
public removeColumn(Column|string $column)

Removes a column from the table.

Parameters

Column|string $column The Column or its name

at line 539
public adjustColumnPositions()

at line 554
public ForeignKey addForeignKey(ForeignKey|array $fkdata)

Adds a new foreign key to this table.

Parameters

ForeignKey|array $fkdata

Return Value

ForeignKey

at line 581
public Column getChildrenColumn()

Returns the column that subclasses the class representing this table can be produced from.

Return Value

Column

at line 591
public array getChildrenNames()

Returns the subclasses that can be created from this table.

Return Value

array

at line 611
public addReferrer(ForeignKey $fk)

Adds the foreign key from another table that refers to this table.

Parameters

ForeignKey $fk

at line 621
public array getReferrers()

Returns the list of references to this table.

Return Value

array

at line 634
public setupReferrers(boolean $throwErrors = false)

Browses the foreign keys and creates referrers for the foreign table.

This method can be called several times on the same table. It only
adds the missing referrers and is non-destructive.
Warning: only use when all the tables were created.

Parameters

boolean $throwErrors

at line 707
public array getCrossFks()

Returns the list of cross foreign keys.

Return Value

array

at line 726
public boolean setContainsForeignPK($b)

Sets whether or not this table contains a foreign primary key.

Parameters

$b

Return Value

boolean

at line 736
public boolean getContainsForeignPK()

Returns whether or not this table contains a foreign primary key.

Return Value

boolean

at line 746
public array getForeignTableNames()

Returns the list of tables referenced by foreign keys in this table.

Return Value

array

at line 756
public boolean requiresTransactionInPostgres()

Return true if the column requires a transaction in Postgres.

Return Value

boolean

at line 766
public addIdMethodParameter(IdMethodParameter $idMethodParameter)

Adds a new parameter for the strategy that generates primary keys.

Parameters

IdMethodParameter $idMethodParameter

at line 787
public removeIndex(string $name)

Removes a index from the table.

Parameters

string $name

at line 805
public bool hasIndex(string $name)

Checks if the table has a index by name.

Parameters

string $name

Return Value

bool

at line 823
public Index addIndex(Index $index)

Adds a new index to the indices list and set the parent table of the column to the current table.

Parameters

Index $index

Return Value

Index

at line 847
public Unique addUnique(Unique $unique)

Adds a new Unique index to the list of unique indices and set the parent table of the column to the current table.

Parameters

Unique $unique

Return Value

Unique

at line 868
public GeneratorConfig getGeneratorConfig()

Retrieves the configuration object, filled by build.properties

Return Value

GeneratorConfig

at line 878
public Behavior addBehavior($bdata)

Adds a new Behavior to the table.

Parameters

$bdata

Return Value

Behavior $bdata

at line 900
public array getBehaviors()

Returns the list of table behaviors.

Return Value

array

at line 911
public boolean hasBehavior(string $name)

check if the table has a behavior by name

Parameters

string $name the behavior name

Return Value

boolean True if the behavior exists

at line 922
public Behavior getBehavior(string $name)

Get one table behavior by name

Parameters

string $name the behavior name

Return Value

Behavior a behavior object

at line 932
public boolean hasAdditionalBuilders()

Returns whether or not the table behaviors offer additional builders.

Return Value

boolean

at line 947
public Array getEarlyBehaviors()

Get the early table behaviors

Return Value

Array of Behavior objects

at line 964
public array getAdditionalBuilders()

Returns the list of additional builders provided by the table behaviors.

Return Value

array

at line 979
public string getName()

Returns the full table name (including schema name when possible).

Return Value

string

at line 997
public string getDescription()

Returns the table description.

Return Value

string

at line 1007
public boolean hasDescription()

Returns whether or not the table has a description.

Return Value

boolean

at line 1017
public setDescription(string $description)

Sets the table description.

Parameters

string $description

at line 1028
public string getPhpName()

Returns the name to use in PHP sources.

Return Value

string

Exceptions

EngineException

at line 1046
public setPhpName(string $phpName)

Sets the name to use in PHP sources.

Parameters

string $phpName

at line 1068
public string getStudlyPhpName()

Returns the studly version of PHP name.

The studly name is the PHP name with the first character lowercase.

Return Value

string

at line 1078
public string getCommonName()

Returns the common name (without schema name).

Return Value

string

at line 1088
public setCommonName(string $name)

Sets the table common name (without schema name).

Parameters

string $name

at line 1101
public setDefaultStringFormat(string $format)

Sets the default string format for ActiveRecord objects in this table.

Any of 'XML', 'YAML', 'JSON', or 'CSV'.

Parameters

string $format

Exceptions

InvalidArgumentException

at line 1119
public string getDefaultStringFormat()

Returns the default string format for ActiveRecord objects in this table, or the one for the whole database if not set.

Return Value

string

at line 1136
public string getIdMethod()

Returns the method strategy for generating primary keys.

[HL] changing behavior so that Database default method is returned
if no method has been specified for the table.

Return Value

string

at line 1147
public boolean isAllowPkInsert()

Returns whether we allow to insert primary keys on tables with native id method.

Return Value

boolean

at line 1157
public setIdMethod(string $idMethod)

Sets the method strategy for generating primary keys.

Parameters

string $idMethod

at line 1168
public boolean isSkipSql()

Returns whether or not Propel has to skip DDL SQL generation for this table (in the event it should not be created from scratch).

Return Value

boolean

at line 1178
public setSkipSql(boolean $skip)

Sets whether or not this table should have its SQL DDL code generated.

Parameters

boolean $skip

at line 1189
public boolean isReadOnly()

Returns whether or not this table is read-only.

If yes, only only
accessors and relationship accessors and mutators will be generated.

Return Value

boolean

at line 1198
public boolean isReloadOnInsert()

Whether to force object to reload on INSERT.

Return Value

boolean

at line 1208
public boolean isReloadOnUpdate()

Returns whether or not to force object to reload on UPDATE.

Return Value

boolean

at line 1218
public string getAlias()

Returns the PHP name of an active record object this entry references.

Return Value

string

at line 1229
public boolean isAlias()

Returns whether or not this table is specified in the schema or if there is just a foreign key reference to it.

Return Value

boolean

at line 1240
public setAlias(string $alias)

Sets whether or not this table is specified in the schema or if there is just a foreign key reference to it.

Parameters

string $alias

at line 1250
public string getInterface()

Returns the interface objects of this table will implement.

Return Value

string

at line 1260
public setInterface(string $interface)

Sets the interface objects of this table will implement.

Parameters

string $interface

at line 1273
public boolean isAbstract()

Returns whether or not a table is abstract, it marks the business object class that is generated as being abstract.

If you have a table called
"FOO", then the Foo business object class will be declared abstract. This
helps support class hierarchies

Return Value

boolean

at line 1286
public setAbstract(boolean $isAbstract)

Sets whether or not a table is abstract, it marks the business object class that is generated as being abstract.

If you have a
table called "FOO", then the Foo business object class will be
declared abstract. This helps support class hierarchies

Parameters

boolean $isAbstract

at line 1296
public Column[] getColumns()

Returns an array containing all Column objects in the table.

Return Value

Column[]

at line 1306
public integer getNumColumns()

Returns the number of columns in this table.

Return Value

integer

at line 1316
public integer getNumLazyLoadColumns()

Returns the number of lazy loaded columns in this table.

Return Value

integer

at line 1333
public boolean hasEnumColumns()

Returns whether or not one of the columns is of type ENUM.

Return Value

boolean

at line 1349
public array getForeignKeys()

Returns the list of all foreign keys.

Return Value

array

at line 1358
public getIdMethodParameters()

Returns a Collection of parameters relevant for the chosen id generation method.

at line 1368
public array getIndices()

Returns the list of all indices of this table.

Return Value

array

at line 1378
public array getUnices()

Returns the list of all unique indices of this table.

Return Value

array

at line 1390
public boolean hasColumn(Column|string $column, boolean $caseInsensitive = false)

Returns whether or not the table has a column.

Parameters

Column|string $column The Column object or its name
boolean $caseInsensitive Whether the check is case insensitive.

Return Value

boolean

at line 1410
public Column getColumn(string $name, boolean $caseInsensitive = false)

Returns the Column object with the specified name.

Parameters

string $name The name of the column (e.g. 'my_column')
boolean $caseInsensitive Whether the check is case insensitive.

Return Value

Column

at line 1429
public Column getColumnByPhpName(string $phpName)

Returns a specified column by its php name.

Parameters

string $phpName

Return Value

Column

at line 1445
public array getForeignKeysReferencingTable(string $tableName)

Returns all foreign keys from this table that reference the table passed in argument.

Parameters

string $tableName

Return Value

array

at line 1467
public array getColumnForeignKeys(string $column)

Returns the foreign keys that include column in it's list of local columns.

Eg. Foreign key (a, b, c) references tbl(x, y, z) will be returned of col
is either a, b or c.

Parameters

string $column Name of the column

Return Value

array

at line 1484
public setDatabase(Database $database)

Set the database that contains this table.

Parameters

Database $database

at line 1494
public Database getDatabase()

Get the database that contains this table.

Return Value

Database

at line 1504
public PlatformInterface getPlatform()

Returns the Database platform.

Return Value

PlatformInterface

at line 1516
public boolean isForReferenceOnly()

Returns whether or not code and SQL must be created for this table.

Table will be skipped, if return true.

Return Value

boolean

at line 1526
public setForReferenceOnly(boolean $v)

Returns whether or not to determine if code/sql gets created for this table.

Table will be skipped, if set to true.

Parameters

boolean $v

at line 1536
public appendXml(DOMNode $node)

Appends XML nodes to passed-in DOMNode.

Parameters

DOMNode $node

at line 1634
public Column[] getPrimaryKey()

Returns the collection of Columns which make up the single primary key for this table.

Return Value

Column[]

at line 1651
public boolean hasPrimaryKey()

Returns whether or not this table has a primary key.

Return Value

boolean

at line 1661
public boolean hasCompositePrimaryKey()

Returns whether or not this table has a composite primary key.

Return Value

boolean

at line 1673
public Column getFirstPrimaryKeyColumn()

Returns the first primary key column.

Useful for tables with a PK using a single column.

Return Value

Column

at line 1687
public boolean hasAutoIncrementPrimaryKey()

Returns whether or not this table has any auto-increment primary keys.

Return Value

boolean

at line 1697
public Column getAutoIncrementPrimaryKey()

Returns the auto incremented primary key.

Return Value

Column

at line 1714
public boolean getIsCrossRef()

Returns whether or not there is a cross reference status for this foreign key.

Return Value

boolean

at line 1724
public boolean isCrossRef()

Alias for Table::getIsCrossRef.

Return Value

boolean

at line 1734
public setIsCrossRef(boolean $isCrossRef)

Sets a cross reference status for this foreign key.

Parameters

boolean $isCrossRef

at line 1744
public boolean hasForeignKeys()

Returns whether or not the table has foreign keys.

Return Value

boolean

at line 1754
public boolean hasCrossForeignKeys()

Returns whether the table has cross foreign keys or not.

Return Value

boolean