Class

Table

class Table extends ScopedElement implements IDMethod

Data about a table used in an application.

Constants

DEBUG

Enables some debug printing.

Methods

value getNamespace()

Get the value of the namespace.

from ScopedElement
setNamespace($v $v)

Set the value of the namespace.

from ScopedElement
value getPackage()

Get the value of package.

from ScopedElement
setPackage($v $v)

Set the value of package.

from ScopedElement
value getSchema()

Get the value of schema.

from ScopedElement
setSchema($v $v)

Set the value of schema.

from ScopedElement
__construct(string $name = null)

Constructs a table object with a name

setupObject()

Sets up the Rule object based on the attributes that were passed to loadFromXML().

string getBuildProperty(string $key)

get a build property for the database this table belongs to

applyBehaviors()

Execute behavior table modifiers

doFinalInitialization()

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.

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 $delim = ',')

Creates a delimiter-delimited string list of column names

doNaming()

Names composing objects which haven't yet been named.

The getBaseClass()

Gets the value of base class for classes produced from this table.

setBaseClass(v $v)

Set the value of baseClass.

value getBasePeer()

Get the value of basePeer.

setBasePeer(v $v)

Set the value of basePeer.

Column addColumn($data)

A utility function to create a new column from attrib and add it to this table.

removeColumn(Column|string $col)

Removed a column from the table

adjustColumnPositions()

Validator addValidator(mixed $data)

Add a validator to this table.

removeValidatorForColumn(string $columnName)

Removes validators based on a column name

addForeignKey($fkdata)

A utility function to create a new foreign key from attrib and add it to this table.

Column getChildrenColumn()

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

array getChildrenNames()

Get the subclasses that can be created from this table.

addReferrer(ForeignKey $fk)

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

getReferrers()

Get list of references to this table.

setupReferrers($throwErrors = false)

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

getCrossFks()

setContainsForeignPK($b)

Set whether this table contains a foreign PK

getContainsForeignPK()

Determine if this table contains a foreign PK

getForeignTableNames()

A list of tables referenced by foreign keys in this table

requiresTransactionInPostgres()

Return true if the column requires a transaction in Postgres

addIdMethodParameter($impdata)

A utility function to create a new id method parameter from attrib or object and add it to this table.

removeIndex(string $name)

Removed a index from the table

bool hasIndex(string $name)

check if the table has a index by name

addIndex($idxdata)

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

addUnique($unqdata)

Adds a new Unique to the Unique list 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

Behavior[] getBehaviors()

Get the table behaviors

Behavior[] getEarlyBehaviors()

Get the early 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()

Check whether one of the table behaviors offer an additional builder

array getAdditionalBuilders()

Get the additional builders provided by the table behaviors

getName()

Get the name of the Table

getDescription()

Get the description for the Table

hasDescription()

Whether the Table has a description

setDescription(newDescription $newDescription)

Set the description for the Table

string getPhpName()

Get name to use in PHP sources

setPhpName(string $phpName)

Set name to use in PHP sources

buildPhpName($name)

string getStudlyPhpName()

Get studly version of PHP name.

getCommonName()

Get the name without schema

setCommonName($v)

Set the common name of the table (without schema)

setDefaultStringFormat(string $defaultStringFormat)

Set the default string format for ActiveRecord objects in this Table.

string getDefaultStringFormat()

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

string getIdMethod()

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

boolean isAllowPkInsert()

Whether we allow to insert primary keys on tables with idMethod=native

setIdMethod($idMethod)

Set the method for generating pk's

boolean isSkipSql()

Skip generating sql for this table (in the event it should not be created from scratch).

boolan isReadOnly()

Is table read-only, in which case only accessors (and relationship setters) will be created.

setSkipSql(boolean $v)

Set whether this table should have its creation sql generated.

boolean isReloadOnInsert()

Whether to force object to reload on INSERT.

boolean isReloadOnUpdate()

Whether to force object to reload on UPDATE.

string getAlias()

PhpName of om object this entry references.

boolean isAlias()

Is this table specified in the schema or is there just a foreign key reference to it.

setAlias(string $v)

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

string getInterface()

Interface which objects for this table will implement

setInterface(string $v)

Interface which objects for this table will implement

boolean isAbstract()

When a table is abstract, it marks the business object class that is generated as being abstract.

setAbstract(boolean $v)

When a table is abstract, it marks the business object class that is generated as being abstract.

Column[] getColumns()

Returns an Array containing all the columns in the table

getNumColumns()

Utility method to get the number of columns in this table

getNumLazyLoadColumns()

Utility method to get the number of columns in this table

boolean hasEnumColumns()

Checks whether one of the columns is of type ENUM

Validator[] getValidators()

Returns an Array containing all the validators in the table

ForeignKey[] getForeignKeys()

Returns an Array containing all the FKs in the table.

getIdMethodParameters()

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

array getIndices()

Returns an Array containing all the FKs in the table

array getUnices()

Returns an Array containing all the UKs in the table

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

Check whether the table has a column.

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

Return the column with the specified name.

Column getColumnByPhpName($phpName)

Returns a specified column.

array getForeignKeysReferencingTable($tablename)

Get all the foreign keys from this table to the specified table.

array getColumnForeignKeys($colname)

Return the foreign keys that includes col in it's list of local columns.

boolean containsColumn(Column|string $col)

Check whether the table has a column.

setDatabase(Database $db)

Set the database that contains this table.

Database getDatabase()

Get the database that contains this table.

boolean isForReferenceOnly()

Flag to determine if code/sql gets created for this table.

setForReferenceOnly(boolean $v)

Flag to determine if code/sql gets created for this table.

string treeMode()

Flag to determine if tree node class should be generated for this table.

setTreeMode(string $v)

Flag to determine if tree node class should be generated 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()

Determine whether this table has a primary key.

boolean hasCompositePrimaryKey()

Determine whether this table has a composite primary key.

getFirstPrimaryKeyColumn()

Get the first column of the primary key.

boolean hasAutoIncrementPrimaryKey()

Determine whether this table has any auto-increment primary key(s).

Column|null getAutoIncrementPrimaryKey()

Gets the auto increment PK

A printPrimaryKey()

Returns all parts of the primary key, separated by commas.

boolean getIsCrossRef()

Gets the crossRef status for this foreign key

setIsCrossRef(boolean $isCrossRef)

Sets a crossref status for this foreign key.

Boolean hasForeignKeys()

Returns whether the table has foreign keys or not.

Boolean hasCrossForeignKeys()

Returns whether the table has cross foreign keys or not.

string getNonPrefixedName()

Details

in ScopedElement at line 73
public value getNamespace()

Get the value of the namespace.

Return Value

value of namespace.

in ScopedElement at line 83
public setNamespace($v $v)

Set the value of the namespace.

Parameters

$v $v Value to assign to namespace.

in ScopedElement at line 100
public value getPackage()

Get the value of package.

Return Value

value of package.

in ScopedElement at line 110
public setPackage($v $v)

Set the value of package.

Parameters

$v $v Value to assign to package.

in ScopedElement at line 124
public value getSchema()

Get the value of schema.

Return Value

value of schema.

in ScopedElement at line 134
public setSchema($v $v)

Set the value of schema.

Parameters

$v $v Value to assign to schema.

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

Constructs a table object with a name

Parameters

string $name table name

at line 335
public setupObject()

Sets up the Rule object based on the attributes that were passed to loadFromXML().

See also

parent::loadFromXML()

at line 375
public string getBuildProperty(string $key)

get a build property for the database this table belongs to

Parameters

string $key key of the build property

Return Value

string value of the property

at line 383
public applyBehaviors()

Execute behavior table modifiers

at line 401
public doFinalInitialization()

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.

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

at line 467
public addExtraIndices()

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

at line 580
public string getColumnList(array $columns, string $delim = ',')

Creates a delimiter-delimited string list of column names

Parameters

array $columns Column[] or string[]
string $delim The delimiter to use in separating the column names.

Return Value

string

See also

Platform::getColumnList() if quoting is required

at line 597
public doNaming()

Names composing objects which haven't yet been named.

This currently consists of foreign-key and index entities.

at line 662
public The getBaseClass()

Gets the value of base class for classes produced from this table.

Return Value

The base class for classes produced from this table.

at line 678
public setBaseClass(v $v)

Set the value of baseClass.

Parameters

v $v Value to assign to baseClass.

at line 688
public value getBasePeer()

Get the value of basePeer.

Return Value

value of basePeer.

at line 704
public setBasePeer(v $v)

Set the value of basePeer.

Parameters

v $v Value to assign to basePeer.

at line 718
public Column addColumn($data)

A utility function to create a new column from attrib and add it to this table.

Parameters

$data

Return Value

Column the added column

Exceptions

EngineException

at line 756
public removeColumn(Column|string $col)

Removed a column from the table

Parameters

Column|string $col the column to remove

Exceptions

EngineException

at line 773
public adjustColumnPositions()

at line 794
public Validator addValidator(mixed $data)

Add a validator to this table.

Supports two signatures: - addValidator(Validator $validator) - addValidator(array $attribs)

Parameters

mixed $data Validator object or XML attribs (array) from element.

Return Value

Validator The added Validator.

Exceptions

EngineException

at line 821
public removeValidatorForColumn(string $columnName)

Removes validators based on a column name

Parameters

string $columnName The name of the column bearing a validator.

at line 834
public addForeignKey($fkdata)

A utility function to create a new foreign key from attrib and add it to this table.

Parameters

$fkdata

at line 864
public Column getChildrenColumn()

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

Return Value

Column

at line 874
public array getChildrenNames()

Get the subclasses that can be created from this table.

Return Value

array string[] Class names

at line 891
public addReferrer(ForeignKey $fk)

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

Parameters

ForeignKey $fk

at line 902
public getReferrers()

Get list of references to this table.

at line 913
public setupReferrers($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

$throwErrors

at line 982
public getCrossFks()

at line 999
public setContainsForeignPK($b)

Set whether this table contains a foreign PK

Parameters

$b

at line 1007
public getContainsForeignPK()

Determine if this table contains a foreign PK

at line 1015
public getForeignTableNames()

A list of tables referenced by foreign keys in this table

at line 1027
public requiresTransactionInPostgres()

Return true if the column requires a transaction in Postgres

at line 1036
public addIdMethodParameter($impdata)

A utility function to create a new id method parameter from attrib or object and add it to this table.

Parameters

$impdata

at line 1060
public removeIndex(string $name)

Removed a index from the table

Parameters

string $name

at line 1080
public bool hasIndex(string $name)

check if the table has a index by name

Parameters

string $name

Return Value

bool

at line 1095
public addIndex($idxdata)

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

Parameters

$idxdata

at line 1116
public addUnique($unqdata)

Adds a new Unique to the Unique list and set the parent table of the column to the current table

Parameters

$unqdata

at line 1138
public GeneratorConfig getGeneratorConfig()

Retrieves the configuration object, filled by build.properties

Return Value

GeneratorConfig

at line 1148
public Behavior addBehavior($bdata)

Adds a new Behavior to the table

Parameters

$bdata

Return Value

Behavior A behavior instance

at line 1170
public Behavior[] getBehaviors()

Get the table behaviors

Return Value

Behavior[]

at line 1180
public Behavior[] getEarlyBehaviors()

Get the early table behaviors

Return Value

Behavior[]

at line 1199
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 1211
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 1222
public boolean hasAdditionalBuilders()

Check whether one of the table behaviors offer an additional builder

Return Value

boolean true in the table has at least one behavior with an additional builder, false otherwise

at line 1238
public array getAdditionalBuilders()

Get the additional builders provided by the table behaviors

Return Value

array list of builder class names

at line 1251
public getName()

Get the name of the Table

at line 1263
public getDescription()

Get the description for the Table

at line 1271
public hasDescription()

Whether the Table has a description

at line 1281
public setDescription(newDescription $newDescription)

Set the description for the Table

Parameters

newDescription $newDescription description for the Table

at line 1291
public string getPhpName()

Get name to use in PHP sources

Return Value

string

at line 1313
public setPhpName(string $phpName)

Set name to use in PHP sources

Parameters

string $phpName

at line 1318
public buildPhpName($name)

Parameters

$name

at line 1330
public string getStudlyPhpName()

Get studly version of PHP name.

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

Return Value

string

at line 1344
public getCommonName()

Get the name without schema

at line 1352
public setCommonName($v)

Set the common name of the table (without schema)

Parameters

$v

at line 1362
public setDefaultStringFormat(string $defaultStringFormat)

Set the default string format for ActiveRecord objects in this Table.

Parameters

string $defaultStringFormat Any of 'XML', 'YAML', 'JSON', or 'CSV'

at line 1373
public string getDefaultStringFormat()

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

Return Value

string The default string representation

at line 1389
public string getIdMethod()

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

Return Value

string

at line 1404
public boolean isAllowPkInsert()

Whether we allow to insert primary keys on tables with idMethod=native

Return Value

boolean

at line 1413
public setIdMethod($idMethod)

Set the method for generating pk's

Parameters

$idMethod

at line 1424
public boolean isSkipSql()

Skip generating sql for this table (in the event it should not be created from scratch).

Return Value

boolean Value of skipSql.

at line 1435
public boolan isReadOnly()

Is table read-only, in which case only accessors (and relationship setters) will be created.

Return Value

boolan Value of readOnly.

at line 1445
public setSkipSql(boolean $v)

Set whether this table should have its creation sql generated.

Parameters

boolean $v Value to assign to skipSql.

at line 1455
public boolean isReloadOnInsert()

Whether to force object to reload on INSERT.

Return Value

boolean

at line 1465
public boolean isReloadOnUpdate()

Whether to force object to reload on UPDATE.

Return Value

boolean

at line 1475
public string getAlias()

PhpName of om object this entry references.

Return Value

string

at line 1486
public boolean isAlias()

Is this table specified in the schema or is there just a foreign key reference to it.

Return Value

boolean

at line 1497
public setAlias(string $v)

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

Parameters

string $v

at line 1507
public string getInterface()

Interface which objects for this table will implement

Return Value

string

at line 1517
public setInterface(string $v)

Interface which objects for this table will implement

Parameters

string $v

at line 1530
public boolean isAbstract()

When 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 BO will be public abstract class Foo This helps support class hierarchies

Return Value

boolean

at line 1544
public setAbstract(boolean $v)

When 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 BO will be public abstract class Foo This helps support class hierarchies

Parameters

boolean $v

at line 1554
public Column[] getColumns()

Returns an Array containing all the columns in the table

Return Value

Column[]

at line 1562
public getNumColumns()

Utility method to get the number of columns in this table

at line 1570
public getNumLazyLoadColumns()

Utility method to get the number of columns in this table

at line 1587
public boolean hasEnumColumns()

Checks whether one of the columns is of type ENUM

Return Value

boolean

at line 1604
public Validator[] getValidators()

Returns an Array containing all the validators in the table

Return Value

Validator[]

at line 1614
public ForeignKey[] getForeignKeys()

Returns an Array containing all the FKs in the table.

Return Value

ForeignKey[]

at line 1623
public getIdMethodParameters()

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

at line 1633
public array getIndices()

Returns an Array containing all the FKs in the table

Return Value

array Index[]

at line 1643
public array getUnices()

Returns an Array containing all the UKs in the table

Return Value

array Unique[]

at line 1656
public boolean hasColumn(Column|string $col, boolean $caseInsensitive = false)

Check whether the table has a column.

Parameters

Column|string $col the column object or name (e.g. 'my_column')
boolean $caseInsensitive Whether the check is case insensitive. False by default.

Return Value

boolean

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

Return the column with the specified name.

Parameters

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

Return Value

Column a Column object or null if it doesn't exist

at line 1694
public Column getColumnByPhpName($phpName)

Returns a specified column.

Parameters

$phpName

Return Value

Column Return a Column object or null if it does not exist.

at line 1708
public array getForeignKeysReferencingTable($tablename)

Get all the foreign keys from this table to the specified table.

Parameters

$tablename

Return Value

array ForeignKey[]

at line 1729
public array getColumnForeignKeys($colname)

Return the foreign keys that includes col 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

$colname

Return Value

array ForeignKey[] or null if there is no FK for specified column.

at line 1749
public boolean containsColumn(Column|string $col)

Check whether the table has a column.

Parameters

Column|string $col the column object or name (e.g. 'my_column')

Return Value

boolean

at line 1759
public setDatabase(Database $db)

Set the database that contains this table.

Parameters

Database $db

at line 1769
public Database getDatabase()

Get the database that contains this table.

Return Value

Database

at line 1780
public boolean isForReferenceOnly()

Flag to determine if code/sql gets created for this table.

Table will be skipped, if return true.

Return Value

boolean

at line 1791
public setForReferenceOnly(boolean $v)

Flag to determine if code/sql gets created for this table.

Table will be skipped, if set to true.

Parameters

boolean $v

at line 1801
public string treeMode()

Flag to determine if tree node class should be generated for this table.

Return Value

string

at line 1811
public setTreeMode(string $v)

Flag to determine if tree node class should be generated for this table.

Parameters

string $v

at line 1821
public appendXml(DOMNode $node)

Appends XML nodes to passed-in DOMNode.

Parameters

DOMNode $node

at line 1931
public Column[] getPrimaryKey()

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

Return Value

Column[] A list of the primary key parts.

at line 1948
public boolean hasPrimaryKey()

Determine whether this table has a primary key.

Return Value

boolean Whether this table has any primary key parts.

at line 1958
public boolean hasCompositePrimaryKey()

Determine whether this table has a composite primary key.

Return Value

boolean Whether this table has more than one primary key parts.

at line 1967
public getFirstPrimaryKeyColumn()

Get the first column of the primary key.

Useful for tables with a PK using a single column.

at line 1981
public boolean hasAutoIncrementPrimaryKey()

Determine whether this table has any auto-increment primary key(s).

Return Value

boolean Whether this table has a non-"none" id method and has a primary key column that is auto-increment.

at line 2000
public Column|null getAutoIncrementPrimaryKey()

Gets the auto increment PK

Return Value

Column|null

at line 2020
public A printPrimaryKey()

Returns all parts of the primary key, separated by commas.

Return Value

A CSV list of primary key parts.

at line 2030
public boolean getIsCrossRef()

Gets the crossRef status for this foreign key

Return Value

boolean

at line 2040
public setIsCrossRef(boolean $isCrossRef)

Sets a crossref status for this foreign key.

Parameters

boolean $isCrossRef

at line 2072
public Boolean hasForeignKeys()

Returns whether the table has foreign keys or not.

Return Value

Boolean

at line 2082
public Boolean hasCrossForeignKeys()

Returns whether the table has cross foreign keys or not.

Return Value

Boolean

at line 2090
public string getNonPrefixedName()

Return Value

string