Class

TableMap

class TableMap

TableMap is used to model a table in a database.

GENERAL NOTE

The propel.map classes are abstract building-block classes for modeling the database at runtime. These classes are similar (a lite version) to the propel.engine.database.model classes, which are build-time modeling classes. These classes in themselves do not do any database metadata lookups.

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 descendents

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.

string getPeerClassname()

Get the Peer 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($pkInfo $pkInfo)

Sets the name of the sequence used to generate a key

An 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.

hasColumnByInsensitiveCase($colName)

getColumnByInsensitiveCase($colName)

ColumnMap[] getColumns()

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

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

Add a primary key column to this Table.

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

Add a foreign key column to the table.

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

Add a foreign primary key column to the table.

boolean isCrossRef()

setIsCrossRef(boolean $isCrossRef)

set the isCrossRef

array getPrimaryKeys()

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

array getForeignKeys()

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

void addValidator(string $columnName, string $name, string $classname, string $value, string $message)

Add a validator to a table's column

buildRelations()

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

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

RelationMap[] 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|null getPrimaryStringColumn()

Gets the ColumnMap for the primary string column.

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

Does this table contain the specified column?

ColumnMap[] getPrimaryKeyColumns()

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

string getPrefix()

Get table prefix name.

void setPrefix(string $prefix)

Set table prefix name.

string removeUnderScores(string $data)

Removes the PREFIX, removes the underscores and makes first letter caps.

Details

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

Construct a new TableMap.

Parameters

$name
$dbMap

at line 116
public initialize()

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

at line 125
public setDatabaseMap(DatabaseMap $dbMap)

Set the DatabaseMap containing this TableMap.

Parameters

DatabaseMap $dbMap A DatabaseMap.

at line 135
public DatabaseMap getDatabaseMap()

Get the DatabaseMap containing this TableMap.

Return Value

DatabaseMap A DatabaseMap.

at line 145
public setName(string $name)

Set the name of the Table.

Parameters

string $name The name of the table.

at line 155
public string getName()

Get the name of the Table.

Return Value

string A String with the name of the table.

at line 165
public setPhpName(string $phpName)

Set the PHP name of the Table.

Parameters

string $phpName The PHP Name for this table

at line 175
public string getPhpName()

Get the PHP name of the Table.

Return Value

string A String with the name of the table.

at line 186
public setClassname(string $classname)

Set the Classname of the Table.

Could be useful for calling Peer and Object methods dynamically.

Parameters

string $classname The Classname

at line 196
public string getClassname()

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

Return Value

string

at line 206
public string getPeerClassname()

Get the Peer Classname of the Propel Class belonging to this table.

Return Value

string

at line 216
public setPackage(string $package)

Set the Package of the Table

Parameters

string $package The Package

at line 226
public string getPackage()

Get the Package of the table.

Return Value

string

at line 236
public setUseIdGenerator(boolean $bit)

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

Parameters

boolean $bit

at line 246
public boolean isUseIdGenerator()

Whether to use Id generator for primary key.

Return Value

boolean

at line 256
public setSingleTableInheritance(boolean $bit)

Set whether or not to this table uses single table inheritance

Parameters

boolean $bit

at line 266
public boolean isSingleTableInheritance()

Whether this table uses single table inheritance

Return Value

boolean

at line 276
public setPrimaryKeyMethodInfo($pkInfo $pkInfo)

Sets the name of the sequence used to generate a key

Parameters

$pkInfo $pkInfo information needed to generate a key

at line 286
public An getPrimaryKeyMethodInfo()

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

Return Value

An Object.

at line 306
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 340
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 355
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 375
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

PropelException if the column is undefined

at line 394
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 407
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

PropelException if the column is undefined

at line 416
public hasColumnByInsensitiveCase($colName)

Parameters

$colName

at line 421
public getColumnByInsensitiveCase($colName)

Parameters

$colName

at line 436
public ColumnMap[] getColumns()

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

Return Value

ColumnMap[]

at line 453
public ColumnMap addPrimaryKey(string $columnName, string $phpName, string $type, boolean $isNotNull = false, int $size = null, string $defaultValue = null)

Add a primary key column to this Table.

Parameters

string $columnName A string with the column name.
string $phpName A string with the php name.
string $type A string specifying the Propel type.
boolean $isNotNull Whether column does not allow NULL values.
int $size An int specifying the size.
string $defaultValue

Return Value

ColumnMap Newly added PrimaryKey column.

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

Add a foreign key column to the table.

Parameters

string $columnName A String with the column name.
string $phpName A string with the php name.
string $type A string specifying the Propel type.
string $fkTable A String with the foreign key table name.
string $fkColumn A String with the foreign key column name.
boolean $isNotNull Whether column does not allow NULL values.
int $size An int specifying the size.
string $defaultValue The default value for this column.

Return Value

ColumnMap Newly added ForeignKey column.

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

Add a foreign primary key column to the table.

Parameters

string $columnName A String with the column name.
string $phpName A string with the php name.
string $type A string specifying the Propel type.
string $fkTable A String with the foreign key table name.
string $fkColumn A String with the foreign key column name.
boolean $isNotNull Whether column does not allow NULL values.
int $size An int specifying the size.
string $defaultValue The default value for this column.

Return Value

ColumnMap Newly created foreign pkey column.

at line 499
public boolean isCrossRef()

Return Value

boolean true if the table is a many to many

at line 509
public setIsCrossRef(boolean $isCrossRef)

set the isCrossRef

Parameters

boolean $isCrossRef

at line 519
public array getPrimaryKeys()

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

Return Value

array ColumnMap[]

at line 529
public array getForeignKeys()

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

Return Value

array ColumnMap[]

at line 545
public void addValidator(string $columnName, string $name, string $classname, string $value, string $message)

Add a validator to a table's column

Parameters

string $columnName The name of the validator's column
string $name The rule name of this validator
string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator)
string $value
string $message The error message which is returned on invalid values

Return Value

void

at line 567
public buildRelations()

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

at line 584
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::MANYTOONE, RelationMap::ONETOMANY, or RelationMAp::ONETOONE)
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 624
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 638
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

PropelException When called on an inexistent relation

at line 653
public RelationMap[] getRelations()

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

Return Value

RelationMap[]

at line 669
public array getBehaviors()

Gets the list of behaviors registered for this table

Return Value

array

at line 679
public boolean hasPrimaryStringColumn()

Does this table has a primaryString column?

Return Value

boolean True if the table has a primaryString column.

at line 689
public ColumnMap|null getPrimaryStringColumn()

Gets the ColumnMap for the primary string column.

Return Value

ColumnMap|null The primary string column, null if none given.

at line 712
public boolean containsColumn(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 738
public ColumnMap[] getPrimaryKeyColumns()

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

Return Value

ColumnMap[]

at line 758
public string getPrefix()

Get table prefix name.

Return Value

string A String with the prefix.

at line 773
public void setPrefix(string $prefix)

Set table prefix name.

Parameters

string $prefix The prefix for the table name (ie: SCARAB for SCARAB_PROJECT).

Return Value

void

at line 818
final public string removeUnderScores(string $data)

Removes the PREFIX, removes the underscores and makes first letter caps.

SCARABFOOBAR becomes FooBar.

Parameters

string $data

Return Value

string A String with data processed.