Flourish PHP Unframework

fORMSchema

static class, v1.0.0b9

Provides fSchema class related functions for ORM code

Changes:
1.0.0b9Enhanced various exception messages 9/19/10
1.0.0b8Added 'one-to-one' support to getRouteNameFromRelationship(), '!many-to-one' to getRoute() 3/3/10
1.0.0b7Added support for multiple databases 10/28/09
1.0.0b6Internal Backwards Compatibility Break - Added the $schema parameter to the beginning of getRoute(), getRouteName(), getRoutes() and isOneToOne() - added '!many-to-one' relationship type handling 10/22/09
1.0.0b5Fixed some error messaging to not include {empty_string} in some situations 7/31/09
1.0.0b4Added isOneToOne() 7/21/09
1.0.0b3Added routes caching for performance 6/15/09
1.0.0b2Backwards Compatiblity Break - removed enableSmartCaching(), fORM::enableSchemaCaching() now provides equivalent functionality 5/4/09
1.0.0bThe initial implementation 6/14/07

Static Methods

::attach() public

Allows attaching an fSchema-compatible object as the schema singleton for ORM code

Signature

void attach( fSchema $schema, string $name='default' )

Parameters

fSchema $schema An object that is compatible with fSchema
string $name The name of the database this schema is for

::getRoute() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Returns information about the specified route

Signature

void getRoute( fSchema $schema, string $table, string $related_table, string $route, string $relationship_type=NULL )

Parameters

fSchema $schema The schema object to get the route from
string $table The main table we are searching on behalf of
string $related_table The related table we are searching under
string $route The route to get info about
string $relationship_type The relationship type: NULL, '*-to-many', '*-to-one', '!many-to-one', 'one-to-one', 'one-to-meny', 'many-to-one', 'many-to-many'

::getRouteName() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Returns the name of the only route from the specified table to one of its related tables

Signature

string getRouteName( fSchema $schema, string $table, string $related_table, string $route=NULL, string $relationship_type=NULL )

Parameters

fSchema $schema The schema object to get the route name from
string $table The main table we are searching on behalf of
string $related_table The related table we are trying to find the routes for
string $route The route that was preselected, will be verified if present
string $relationship_type The relationship type: NULL, '*-to-many', '*-to-one', '!many-to-one', 'one-to-one', 'one-to-many', 'many-to-one', 'many-to-many'

Returns

The only route from the main table to the related table

::getRouteNameFromRelationship() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Returns the name of the route specified by the relationship

Signature

string getRouteNameFromRelationship( string $type, array $relationship )

Parameters

string $type The type of relationship: '*-to-one', 'one-to-one', 'one-to-many', 'many-to-one', 'many-to-many'
array $relationship The relationship array from fSchema::getKeys()

Returns

The name of the route

::getRoutes() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Returns an array of all routes from a table to one of its related tables

Signature

array getRoutes( fSchema $schema, string $table, string $related_table, string $relationship_type=NULL )

Parameters

fSchema $schema The schema object to get the routes for
string $table The main table we are searching on behalf of
string $related_table The related table we are trying to find the routes for
string $relationship_type The relationship type: NULL, '*-to-many', '*-to-one', '!many-to-one', 'one-to-one', 'one-to-many', 'many-to-one', 'many-to-many'

Returns

All of the routes from the main table to the related table

::isOneToOne() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Indicates if the relationship specified is a one-to-one relationship

Signature

boolean isOneToOne( fSchema $schema, string $table, string $related_table, string $route=NULL )

Parameters

fSchema $schema The schema object the tables are from
string $table The main table we are searching on behalf of
string $related_table The related table we are trying to find the routes for
string $route The route between the two tables

Returns

If the table is in a one-to-one relationship with the related table over the route specified

::reset() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Resets the configuration of the class

Signature

void reset( )

::retrieve() public

Return the instance of the fSchema class

Signature

fSchema retrieve( string $class='fActiveRecord' )

Parameters

string $class The class the object will be used with

Returns

The schema instance