Propel 2 API
Class

Propel\Runtime\Map\TableMap

class TableMap

TableMap is used to model a table in a database.

Constants

TYPE_PHPNAME

phpname type e.g.

'AuthorId'

TYPE_STUDLYPHPNAME

studlyphpname type e.g.

'authorId'

TYPE_COLNAME

column (tableMap) name type e.g.

'book.AUTHOR_ID'

TYPE_RAW_COLNAME

column part of the column tableMap name e.g.

'AUTHOR_ID'

TYPE_FIELDNAME

column fieldname type e.g.

'author_id'

TYPE_NUM

num type simply the numerical array index, e.g.

4

Methods

__construct($name = null, $dbMap = null)

Construct a new TableMap.

initialize()

Initialize the TableMap to build columns, relations, etc This method should be overridden by descendants

setDatabaseMap(DatabaseMap $dbMap)

Set the DatabaseMap containing this TableMap.

DatabaseMap getDatabaseMap()

Get the DatabaseMap containing this TableMap.

setName(string $name)

Set the name of the Table.

string getName()

Get the name of the Table.

setPhpName(string $phpName)

Set the PHP name of the Table.

string getPhpName()

Get the PHP name of the Table.

setClassName(string $classname)

Set the ClassName of the Table.

string getClassName()

Get the ClassName of the Propel Class belonging to this table.

setPackage(string $package)

Set the Package of the Table

string getPackage()

Get the Package of the table.

setUseIdGenerator(boolean $bit)

Set whether or not to use Id generator for primary key.

boolean isUseIdGenerator()

Whether to use Id generator for primary key.

setSingleTableInheritance(boolean $bit)

Set whether or not to this table uses single table inheritance

boolean isSingleTableInheritance()

Whether this table uses single table inheritance

setPrimaryKeyMethodInfo(mixed $pkInfo)

Sets the name of the sequence used to generate a key

mixed getPrimaryKeyMethodInfo()

Get the name of the sequence used to generate a primary key

ColumnMap addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null)

Add a column to the table.

ColumnMap addConfiguredColumn(ColumnMap $cmap)

Add a pre-created column to this table.

boolean hasColumn(mixed $name, boolean $normalize = true)

Does this table contain the specified column?

ColumnMap getColumn(string $name, boolean $normalize = true)

Get a ColumnMap for the table.

boolean hasColumnByPhpName(mixed $phpName)

Does this table contain the specified column?

ColumnMap getColumnByPhpName(string $phpName)

Get a ColumnMap for the table.

ColumnMap[] getColumns()

Get a ColumnMap[] of the columns in this table.

ColumnMap addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null)

Add a primary key column to this Table.

ColumnMap addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size, $defaultValue = null)

Add a foreign key column to the table.

ColumnMap addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size, $defaultValue = null)

Add a foreign primary key column to the table.

boolean isCrossRef()

setIsCrossRef(boolean $isCrossRef)

Set the isCrossRef

ColumnMap[] getPrimaryKeys()

Returns array of ColumnMap objects that make up the primary key for this table

ColumnMap[] getForeignKeys()

Returns array of ColumnMap objects that are foreign keys for this table

buildRelations()

Build relations Relations are lazy loaded for performance reasons This method should be overridden by descendants

RelationMap addRelation(string $name, string $tablePhpName, integer $type, array $columnMapping = array(), string $onDelete = null, string $onUpdate = null, string $pluralName = null)

Adds a RelationMap to the table

boolean hasRelation(string $name)

Gets a RelationMap of the table by relation name This method will build the relations if they are not built yet

RelationMap getRelation(string $name)

Gets a RelationMap of the table by relation name This method will build the relations if they are not built yet

array getRelations()

Gets the RelationMap objects of the table This method will build the relations if they are not built yet

array getBehaviors()

Gets the list of behaviors registered for this table

boolean hasPrimaryStringColumn()

Does this table has a primaryString column?

ColumnMap getPrimaryStringColumn()

Gets the ColumnMap for the primary string column.

static mixed doInsert(Criteria $criteria, ConnectionInterface $con = null)

Method to perform inserts based on values and keys in a Criteria.

static  getFieldnamesForClass($classname, $type = TableMap::TYPE_PHPNAME)

static  translateFieldnameForClass($classname, $fieldname, $fromType, $toType)

Details

at line 174
public __construct($name = null, $dbMap = null)

Construct a new TableMap.

Parameters

$name
$dbMap

at line 189
public initialize()

Initialize the TableMap to build columns, relations, etc This method should be overridden by descendants

at line 198
public setDatabaseMap(DatabaseMap $dbMap)

Set the DatabaseMap containing this TableMap.

Parameters

DatabaseMap $dbMap A DatabaseMap.

at line 208
public DatabaseMap getDatabaseMap()

Get the DatabaseMap containing this TableMap.

Return Value

DatabaseMap A DatabaseMap.

at line 218
public setName(string $name)

Set the name of the Table.

Parameters

string $name The name of the table.

at line 228
public string getName()

Get the name of the Table.

Return Value

string A String with the name of the table.

at line 238
public setPhpName(string $phpName)

Set the PHP name of the Table.

Parameters

string $phpName The PHP Name for this table

at line 248
public string getPhpName()

Get the PHP name of the Table.

Return Value

string A String with the name of the table.

at line 259
public setClassName(string $classname)

Set the ClassName of the Table.

Could be useful for calling
tableMap and Object methods dynamically.

Parameters

string $classname The ClassName

at line 269
public string getClassName()

Get the ClassName of the Propel Class belonging to this table.

Return Value

string

at line 279
public setPackage(string $package)

Set the Package of the Table

Parameters

string $package The Package

at line 289
public string getPackage()

Get the Package of the table.

Return Value

string

at line 299
public setUseIdGenerator(boolean $bit)

Set whether or not to use Id generator for primary key.

Parameters

boolean $bit

at line 309
public boolean isUseIdGenerator()

Whether to use Id generator for primary key.

Return Value

boolean

at line 319
public setSingleTableInheritance(boolean $bit)

Set whether or not to this table uses single table inheritance

Parameters

boolean $bit

at line 329
public boolean isSingleTableInheritance()

Whether this table uses single table inheritance

Return Value

boolean

at line 339
public setPrimaryKeyMethodInfo(mixed $pkInfo)

Sets the name of the sequence used to generate a key

Parameters

mixed $pkInfo information needed to generate a key

at line 349
public mixed getPrimaryKeyMethodInfo()

Get the name of the sequence used to generate a primary key

Return Value

mixed

at line 398
public ColumnMap addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null)

Add a column to the table.

Parameters

$name
$phpName
$type
$isNotNull
$size
$defaultValue
$pk
$fkTable
$fkColumn

Return Value

ColumnMap The newly created column.

at line 430
public ColumnMap addConfiguredColumn(ColumnMap $cmap)

Add a pre-created column to this table.

It will replace any
existing column.

Parameters

ColumnMap $cmap A ColumnMap.

Return Value

ColumnMap The added column map.

at line 444
public boolean hasColumn(mixed $name, boolean $normalize = true)

Does this table contain the specified column?

Parameters

mixed $name name of the column or ColumnMap instance
boolean $normalize Normalize the column name (if column name not like FIRST_NAME)

Return Value

boolean True if the table contains the column.

at line 463
public ColumnMap getColumn(string $name, boolean $normalize = true)

Get a ColumnMap for the table.

Parameters

string $name A String with the name of the table.
boolean $normalize Normalize the column name (if column name not like FIRST_NAME)

Return Value

ColumnMap A ColumnMap.

Exceptions

ColumnNotFoundException If the column is undefined

at line 481
public boolean hasColumnByPhpName(mixed $phpName)

Does this table contain the specified column?

Parameters

mixed $phpName name of the column

Return Value

boolean True if the table contains the column.

at line 493
public ColumnMap getColumnByPhpName(string $phpName)

Get a ColumnMap for the table.

Parameters

string $phpName A String with the name of the table.

Return Value

ColumnMap A ColumnMap.

Exceptions

ColumnNotFoundException If the column is undefined

at line 507
public ColumnMap[] getColumns()

Get a ColumnMap[] of the columns in this table.

Return Value

ColumnMap[]

at line 521
public ColumnMap addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null)

Add a primary key column to this Table.

Parameters

$columnName
$phpName
$type
$isNotNull
$size
$defaultValue

Return Value

ColumnMap Newly added PrimaryKey column.

at line 538
public ColumnMap addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size, $defaultValue = null)

Add a foreign key column to the table.

Parameters

$columnName
$phpName
$type
$fkTable
$fkColumn
$isNotNull
$size
$defaultValue

Return Value

ColumnMap Newly added ForeignKey column.

at line 555
public ColumnMap addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size, $defaultValue = null)

Add a foreign primary key column to the table.

Parameters

$columnName
$phpName
$type
$fkTable
$fkColumn
$isNotNull
$size
$defaultValue

Return Value

ColumnMap Newly created foreign pkey column.

at line 563
public boolean isCrossRef()

Return Value

boolean true if the table is a many to many

at line 573
public setIsCrossRef(boolean $isCrossRef)

Set the isCrossRef

Parameters

boolean $isCrossRef

at line 583
public ColumnMap[] getPrimaryKeys()

Returns array of ColumnMap objects that make up the primary key for this table

Return Value

ColumnMap[]

at line 593
public ColumnMap[] getForeignKeys()

Returns array of ColumnMap objects that are foreign keys for this table

Return Value

ColumnMap[]

at line 603
public buildRelations()

Build relations Relations are lazy loaded for performance reasons This method should be overridden by descendants

at line 619
public RelationMap addRelation(string $name, string $tablePhpName, integer $type, array $columnMapping = array(), string $onDelete = null, string $onUpdate = null, string $pluralName = null)

Adds a RelationMap to the table

Parameters

string $name The relation name
string $tablePhpName The related table name
integer $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE)
array $columnMapping An associative array mapping column names (local => foreign)
string $onDelete SQL behavior upon deletion ('SET NULL', 'CASCADE', ...)
string $onUpdate SQL behavior upon update ('SET NULL', 'CASCADE', ...)
string $pluralName Optional plural name for *_TO_MANY relationships

Return Value

RelationMap the built RelationMap object

at line 658
public boolean hasRelation(string $name)

Gets a RelationMap of the table by relation name This method will build the relations if they are not built yet

Parameters

string $name The relation name

Return Value

boolean true if the relation exists

at line 671
public RelationMap getRelation(string $name)

Gets a RelationMap of the table by relation name This method will build the relations if they are not built yet

Parameters

string $name The relation name

Return Value

RelationMap The relation object

Exceptions

RelationNotFoundException When called on an inexistent relation

at line 686
public array getRelations()

Gets the RelationMap objects of the table This method will build the relations if they are not built yet

Return Value

array list of RelationMap objects

at line 702
public array getBehaviors()

Gets the list of behaviors registered for this table

Return Value

array

at line 712
public boolean hasPrimaryStringColumn()

Does this table has a primaryString column?

Return Value

boolean True if the table has a primaryString column.

at line 722
public ColumnMap getPrimaryStringColumn()

Gets the ColumnMap for the primary string column.

Return Value

ColumnMap

at line 756
static public mixed doInsert(Criteria $criteria, ConnectionInterface $con = null)

Method to perform inserts based on values and keys in a Criteria.

<p>
If the primary key is auto incremented the data in Criteria
will be inserted and the auto increment value will be returned.
<p>
If the primary key is included in Criteria then that value will
be used to insert the row.
<p>
If no primary key is included in Criteria then we will try to
figure out the primary key from the database map and insert the
row with the next available id using util.db.IDBroker.
<p>
If no primary key is defined for the table the values will be
inserted as specified in Criteria and null will be returned.

Parameters

Criteria $criteria Object containing values to insert.
ConnectionInterface $con A ConnectionInterface connection.

Return Value

mixed The primary key for the new row if the primary key is auto-generated. Otherwise will return null.

Exceptions

RuntimeException

at line 852
static public getFieldnamesForClass($classname, $type = TableMap::TYPE_PHPNAME)

Parameters

$classname
$type

at line 859
static public translateFieldnameForClass($classname, $fieldname, $fromType, $toType)

Parameters

$classname
$fieldname
$fromType
$toType