Class RSDEngineDB

Description

This class provides the power of creating classes that simplify the acccess of database tables.

Located in /code/framework/RSDEngine/RSDEngineDB.php (line 55)

PEAR
   |
   --RSDEngineDB
Variable Summary
Array $authors
String $columnPrefix
Array $config
String $copyright
String $projectName
Array $relations
String $sql
String $tablePrefix
Array $tables
Method Summary
RSDEngineDB RSDEngineDB (Array $config)
Array getClasses ()
void getControllerFiles (mixed &$argConfig)
Array getFunctions ()
mixed &getTable (mixed $tableName)
Array getTemplateFiles (mixed &$argConfig)
boolean tableExists (mixed $tableName)
mixed _addTable (RSDEngineDBTable $table)
void _checkRelations (mixed $relations)
boolean _createJoinFunctionsForTable (String $tableName)
String _generateNameForCreateSelectIncludingMethod (Array $relations)
void _getRelationsByFromTable (String $fromTable, [Array $relations = false], [Array $excludedTargetTables = array()])
Array _getRelationsRelatedToTable (mixed $tableName, [Array $relations = false], [Array $tables = false], String $fromTable)
boolean _isValidRelationCombination (String $tableName, Array $relations)
void _parse ()
String _removeTablePrefix (String $tableName)
Variables
Array $authors = "" (line 82)

The authors, each stored as one array element. Gets set inside the constructor method.

String $columnPrefix = "" (line 97)

The column prefix used for all columns in $this->sql. Often f_. Providing a column prefix makes the generated code more readable because the prefix can be remove where appropriate. Set in the construtor method.

Array $config = array() (line 102)

An associative array containing all configuration options. Gets set inside the constructor method.

String $copyright = "" (line 87)

The copyright information. This string must not contain newlines. Gets set inside the constructor method.

String $projectName = "" (line 77)

The project name. Gets set inside the constructor method.

Array $relations = array() (line 67)

An array containing instances of RSDEngineRelation.

String $sql = "" (line 72)

The Database schema in SQL DDL. Gets set inside the constructor method.

String $tablePrefix = "" (line 92)

The table prefix used for all tables in $this->sql. Often t_ or an shorthand for the project name of the form prj_. Providing a table prefix makes the generated code more readable because the prefix can be remove where appropriate. Set in the construtor method.

Array $tables = array() (line 61)

An array containing instances of RSDEngineDBTable.

Methods
Constructor RSDEngineDB (line 115)

Initializes this instance.

RSDEngineDB RSDEngineDB (Array $config)
  • Array $config: An associativ array containing the elements 'projectName', 'authors', 'copyright', 'sql', 'tablePrefix', 'columnPrefix'.
getClasses (line 176)

Generates and returns the base and the child class for each table defined in $this->sql.

The generation is performed by $this->_parse(). Each class is stored as an instance of RSDEngineClass.

  • return: An associative array containing all classes the class names are used as the keys.
  • see: RSDEngineDB::_parse()
Array getClasses ()
getControllerFiles (line 202)
void getControllerFiles (mixed &$argConfig)
getFunctions (line 330)

Returns the functions generated by RSDEngineDB in an associative array.

Each function is stored as an instance of RSDEngineFunction. By now now functions are created at all!

  • return: An associative array.
Array getFunctions ()
getTable (line 533)

Returns the table named $tableName or an instance of RSError on failure.

mixed &getTable (mixed $tableName)
getTemplateFiles (line 263)

Returns an associative array containing instances of child classes of RSDEngineFile.

  • return: An associative array.
Array getTemplateFiles (mixed &$argConfig)
tableExists (line 523)

Returns true if the table specified by it's name passed as first argument exists.

boolean tableExists (mixed $tableName)
_addTable (line 385)

Adds an instance of RSDEngineDBTable to the internal stack of RSDEngineDBTable object.

The instance passed as argument is added to the property array tables.

  • return: If a table with such a name already exists or the table name is an empty string an instance of RSError is returned otherwise true.
  • access: private
  • see: RSDEngineDB::$tables
mixed _addTable (RSDEngineDBTable $table)
_checkColumnDuplicates (line 362)

Produces warnings for columns that are not unique.

Column names should be unique because when fetching records from a query joining multiple tables into an assocciative array with the column names as keys, one column might overwrite the other.

void _checkColumnDuplicates ()
_checkRelations (line 627)

Checks if all relations in the array passed as argument have existing starting points and destinations.

The properties fromTable, fromColumn, toTable, toColumn are checked for all relations.

  • access: private
void _checkRelations (mixed $relations)
_collectRelations (line 408)

Copies all RSDRelation objects hold by the RSDEngineDBTable instances in RSDEngineDBTable::realations to RSDEngine::relations.

void _collectRelations ()
_createJoinFunctions (line 451)

Calls createJoin _createJoinFunctionsForTable for each instance of RSDEngineDBTable.

void _createJoinFunctions ()
_createJoinFunctionsForTable (line 469)

Calls RSDEngineDBTable::createSelectIncludingMethod for each combination of relations valid for a table.

RSDEngine::_generateNameForCreateSelectIncludingMethod is used to genertae the method name.

  • return: False if $tableName was an empty string, otherwise true.
  • access: private
boolean _createJoinFunctionsForTable (String $tableName)
  • String $tableName: The name of the table.
_createKeyMethods (line 340)

Calls the method RSDEngineDBTable::createKeyMethods for all RSDEngineDBTable objects.

  • access: private
  • see: RSDEngineDBTable::createKeyMethods
void _createKeyMethods ()
_generateNameForCreateSelectIncludingMethod (line 658)

Returns a name for a selectIncluding* method which is determinated by the relations passed as argument.

  • return: The name of the selectIncluding* method.
  • access: private
String _generateNameForCreateSelectIncludingMethod (Array $relations)
  • Array $relations: An array of relations.
_getRelationsByFromTable (line 583)

Returns an Array containing all relations that have the table specified by the first argument as starting point.

void _getRelationsByFromTable (String $fromTable, [Array $relations = false], [Array $excludedTargetTables = array()])
  • String $fromTable: The name of the table from wich all relations have to start.
  • Array $relations: The array of relations in which to search. This argument is optional. The default is to search in the property relations.
  • Array $excludedTargetTables: An array of table names (strings) the relations must not lead to. This feature is required by _getRelationsRelatedToTable to prevent endless loops. If set to false it is ignored. This argument is optional. The default is false.
_getRelationsRelatedToTable (line 551)

Returns an Array or relations that start from the table $tableName or from the tables these relations point to.

Array _getRelationsRelatedToTable (mixed $tableName, [Array $relations = false], [Array $tables = false], String $fromTable)
  • String $fromTable: The name of the table - the starting point.
  • Array $relations: The array of relations in which to search. This argument is optional. The default is to search in the property relations.
  • Array $tables: An array of strings (table names). Each string represents a table that was already processed.
_isValidRelationCombination (line 612)

Returns true if the combination of relations passed as array as second argument is valid for the table name passed as first argument.

  • return: True if the combination is valid, false otherwise.
  • access: private
boolean _isValidRelationCombination (String $tableName, Array $relations)
  • String $tableName: The name of the table.
  • Array $relations: The combination of relations.
_parse (line 139)

Parses the provided SQL DDL stored in the property $this->sql and generates a RSDEngineDBTable object for each table, stores it in $this->tables.

void _parse ()
_removeTablePrefix (line 678)

Strips the table prefix from a table name and returns it.

String _removeTablePrefix (String $tableName)
  • String $tableName: The name of the table (with prefix).
_setIsKeyForAllColumns (line 423)

Set foreign/primary key related properties for all RSDEngineDBTable objects.

  • access: private
void _setIsKeyForAllColumns ()

Documentation generated on Mon, 8 Dec 2003 13:10:48 +0100 by phpDocumentor 1.2.3