Class RSDEngineDBTable

Description

Creates a class for accassing a database table.

The access restriction for this class should be treated as 'friendly' - only accessable by classes in the same package.

Located in /code/framework/RSDEngine/RSDEngineDBTable.php (line 37)


	
			
Variable Summary
Method Summary
RSDEngineDBTable RSDEngineDBTable (mixed $contents, mixed $projectName, mixed $authors, mixed $copyright, [String $tablePrefix = ""], [String $columnPrefix = ""], mixed &$rsdEngineDB, String $content)
void addMethod (mixed $method)
void columnExists (String $columnName)
void createSelectIncludingMethod (String $methodName, Array $relations)
String getChildClassCode ()
String getChildClassName ()
String getClassName ()
String getCode ()
mixed &getColumn (mixed $columnName)
void getFileOptionProperty (mixed $fileType, mixed $propertyName)
String getInstanceName ()
void getSelectMethodColumns (mixed $methodName)
void prepareSelectIncludingMethod (String $methodName, Array $relations)
String toString ()
mixed _addColumn (RSDEngineColumn $column)
void _addRelation (RSDRelation $relation)
void _addUniqueConstraint (String $columns)
String _getCommaSeperatedListOfColumnNamesForVariableNames ([boolean $quoted = false])
mixed &_getFileOption (String $type)
void _getFileOptionDefaultProperty (mixed $fileType, mixed $propertyName)
mixed _getSelectIncludingMethodName (mixed $tableNames)
boolean _parse ()
nothing _parseBodyLine (mixed $bodyLine)
Variables
Array $authors = "" (line 51)

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

String $columnPrefix = "" (line 68)

The prefix all columns of this table. 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.

  • see: RSDEngineDBTable::RSDEngineDBTable
Array $columns = array() (line 91)

An array that holds all RSDEngineColumn objects for this table. New columns are added by calling the method _addColumn.

String $contents = "" (line 41)

The SQL DDL for this table. Gets set inside the construtor method.

String $copyright = "" (line 56)

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

boolean $ignore = false (line 127)

Whether to ignore this table. Is set inside the method _parse.

The RSDEngineDBTable::_parse will not add the table to its internal stack of tables if $ignore evaluates true.

Array $methods = array() (line 97)

An array that holds the RSDEngineMethod objects for the class to generate. New methods are added by calling addMethod.

String $name = "" (line 73)

The name of the table.

String $projectName = "" (line 46)

The project name. Gets set inside the constructor method.

Array $relations = array() (line 79)

An array of all RSDRelation objects having this table as starting point. New relations are added by calling the method _addRelation.

RSDEngineDB $rsdEngineDB = null (line 102)

Holds a handle to the RSDEngineDB instance that created this instance.

Array $tableOptions = array() (line 107)

An array holding all table options. These are defined between the table name and the opening brace.

String $tablePrefix = "" (line 62)

The prefix of this table. 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.

  • see: RSDEngineDBTable::RSDEngineDBTable
String $_afterDelete = '' (line 212)

PHP Code to be executed after a delete operation.

String $_afterInsert = '' (line 176)

PHP Code to be executed after an insert operation.

String $_afterUpdate = '' (line 194)

PHP Code to be executed after an update operation.

String $_beforeDelete = '' (line 203)

PHP Code to be executed before a delete operation.

String $_beforeInsert = '' (line 167)

PHP Code to be executed before an insert operation.

String $_beforeUpdate = '' (line 185)

PHP Code to be executed before an update operation.

Array $_excludeSelectMethodPatters = array() (line 230)

An array of patterns used to exclude selectIncluding* methods.

Array $_fileOptions = array() (line 148)

An array containing all file table options of this table.

This array get filled by RSDEngineDBTable::_parseTableOptions.

  • see: _parseTableOptions
  • access: private
Array $_includeSelectMethodPatters = array() (line 221)

An array of patterns used to include excluded selectIncluding* methods.

String $_label = '' (line 158)

The label to be used for records of this table.

This property gets set by RSDEngineDBTable::_parseLabelTableOption.

  • see: RSDEngineDBTable::_parseLabelTableOption
  • access: private
Array $_liveUserRights = array() (line 138)

An array containing all LiveUser table options of this table.

This array gets filled by RSDEngineDBTable::_parseTableOptions.

Array $_selectIncludingMethodRelations = array() (line 117)

An array that holds each set of relations that was used to build a selectIncluding method.

New elements are added by createSelectIncludingMethod. This property is required by the method _getSelectIncludingMethodName. Each element will be again an array. The name of the selectIncluding method will be used as key.

Array $_uniqueConstraints = array() (line 85)

An array of all unique constraints of this table. Each constraint is represented by an array holding all column names that build that constraint. New unique constraints are added by calling the method _addUniqueConstraint.

Methods
Constructor RSDEngineDBTable (line 240)

Constructor that initializes this instance and calls parse.

RSDEngineDBTable RSDEngineDBTable (mixed $contents, mixed $projectName, mixed $authors, mixed $copyright, [String $tablePrefix = ""], [String $columnPrefix = ""], mixed &$rsdEngineDB, String $content)
  • String $content: The SQL DDL of the table for which to create this class.
  • String $tablePrefix: The prefix of this table. 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.
  • String $columnPrefix: The prefix all columns of this table use. Often f_. Providing a column prefix makes the generated code more readable because the prefix can be remove where appropriate.
addMethod (line 3869)

Adds an instance of RSDEngineMethod to $this->methods.

void addMethod (mixed $method)
columnExists (line 1367)

Returns true if a column with such a name exists, otherwise false is returned.

Gets called by RSDEngine::_checkRelations

  • access: public
  • see: RSDEngine::_checkRelations
void columnExists (String $columnName)
  • String $columnName: The name of the column.
createKeyMethods (line 297)

Creates all methods that depend an a column that is a primary or a foreign key.

Calls _createDeleteByMethods, _createUpdateByMethods, _createGetByMethods, _createInsertMethod, _createIsValidMethods, _createGetNextMethods, _createStoreUploadedMethods, _createRemoveStoredMethods, _createGetStoredMethods, _createCanUpdate, _createCanDelete, _createCanSelect

void createKeyMethods ()
createSelectIncludingMethod (line 3518)

Creates a selectIncluding* method.

Gets called by RSDEngine::_createJoinFunctionsForTable. RSDEngineDBTable::prepareSelectIncludingMethod should be called before!

  • access: public
  • see: RSDEngineDBTable::prepareSelectIncludingMethod
  • see: RSDEngine::_createJoinFunctionsForTable
void createSelectIncludingMethod (String $methodName, Array $relations)
  • String $methodName: The name of the method to create.
  • Array $relations: An array of relations between tables that should be joined.
getChildClassCode (line 3954)

Returns the code for the child class.

  • return: The code for the child class.
  • access: public
String getChildClassCode ()
getChildClassInstanceName (line 3934)

Returns a reasonalbe name for an instance created from the child class.

  • return: The name of the instance.
  • access: public
String getChildClassInstanceName ()
getChildClassName (line 3924)

Returns the name of generated child class.

The generated child class does nothing but inherit the generated base class. This is because it enables the RSDEngine to update the base class without overwriting what the developer had to code by himself. Man-generated code has to be implemented in the child class! The name is constructed like this:


1 function getChildClassName()
2 {
3 return ucfirst($this->projectName) . ucfirst($this->getTableNameWithoutPrefix());
4 }

  • return: the name of the generated class.
  • access: public
String getChildClassName ()
getClassName (line 3908)

Returns the name of generated class.

The name is constructed like this:


1 function getClassName()
2 {
3 return ucfirst($this->projectName) . ucfirst($this->getTableNameWithoutPrefix()) . "Base";
4 }

  • return: the name of the generated class.
  • access: public
String getClassName ()
getCode (line 3996)

Returns the code for the base class.

  • return: The code for the base class.
  • access: public
String getCode ()
getColumn (line 1377)

Returns the column named $columnName or an instance of RSError on failure.

mixed &getColumn (mixed $columnName)
getDeleteByPrimaryKeyMethodName (line 4100)

Returns the name of the method that can be used to delete records by the primary key from this table.

  • return: the method name.
String getDeleteByPrimaryKeyMethodName ()
getFileOptionProperty (line 1510)
void getFileOptionProperty (mixed $fileType, mixed $propertyName)
getGetByPrimaryKeyMethodName (line 4126)

Returns the name of the method that can be used to retrive records by the primary key from this table.

  • return: the method name.
String getGetByPrimaryKeyMethodName ()
getInstanceName (line 3944)

Returns the name for identifyer that holds a newly created instance of the created class.

  • return: The instance name.
  • access: public
String getInstanceName ()
getPrimaryKeyColumn (line 4084)

Returns the first column defined as primary key

  • return: An instance of RSDEngineColumn or false if no primary key column is found.
mixed getPrimaryKeyColumn ()
getSelectMethodColumns (line 3447)

Returns all columns that are returned from the method selectIncludingAll.

  • see: RSDTalbe::selectIncludingAll
void getSelectMethodColumns (mixed $methodName)
getTableNameForVariableName (line 3895)

Returns the name of this table for use as a variable name.

  • return: The table name for use as variable name.
String getTableNameForVariableName ()
getTableNameWithoutPrefix (line 3880)

Returns the name of this table without the prefix.

String getTableNameWithoutPrefix ()
getUpdateByPrimaryKeyMethodName (line 4113)

Returns the name of the method that can be used to update records by the primary key in this table.

  • return: the method name.
String getUpdateByPrimaryKeyMethodName ()
parseTableOptions (line 453)

Parses the table options saved in $this->tableOptions.

For now there are only LiveUser table options. Gets called by RSDEngineDBTable::_createKeyMethods.

  • access: public
  • see: RSDEngineDBTable::_createKeyMethods
void parseTableOptions ()
prepareSelectIncludingMethod (line 3498)

Does some preparation for the method createSelectIncludingMethod.

This method should be called for all methods before createSelectIncludingMethod is called. This method will fill $this->_selectIncludingMethodRelations.

  • access: public
void prepareSelectIncludingMethod (String $methodName, Array $relations)
  • String $methodName: The name of the method to create.
  • Array $relations: An array of relations between tables that should be joined.
toString (line 271)

Returns a literal representation of this RSDEngineDBTable instance.

String toString ()
_addColumn (line 1342)

Adds an instance of RSDEngineColumn to the array $this->columns.

  • return: True on success and an instance of RSError or failure.
  • access: private
  • see: RSDEngineColumn
  • see: column
mixed _addColumn (RSDEngineColumn $column)
_addRelation (line 1531)

Adds an instance of RSDRelation to the array $this->relations.

void _addRelation (RSDRelation $relation)
  • RSDRelation $relation: An instance of RSDRelation.
_addUniqueConstraint (line 1542)

Adds an array holding representing a unique constraint to the array $this->_uniqueConstraints.

void _addUniqueConstraint (String $columns)
  • String $columns: A comma seperated list of column names building the unique constraint.
_createCanDelete (line 2773)

Creates the method 'canDelete';

  • access: private
void _createCanDelete ()
_createCanSelect (line 2948)

Creates the method 'canDelete';

  • access: private
void _createCanSelect ()
_createCanUpdate (line 2593)

Creates the method 'canUpdate';

  • access: private
void _createCanUpdate ()
_createCanUpdateLiveUserRightMethods (line 1585)

Calls generateUpdateLiveUserRightMethods and generateCanUpdateLiveUserRightMethods on all RSDEngineColumn objects stored in $this->columns.

void _createCanUpdateLiveUserRightMethods ()
_createCheckUniqueConstraintsMethod (line 1717)

Creates the method 'checkUniqueConstrains'.

  • access: private
void _createCheckUniqueConstraintsMethod ()
_createDeleteByMethods (line 3160)

Creates a deleteByCOLUMNNAME method for each column that is a primary or a foreign key.

  • access: private
void _createDeleteByMethods ()
_createDeleteMethod (line 2103)

Creates the method 'delete';

  • access: private
void _createDeleteMethod ()
_createGetByMethods (line 3234)

Creates a getByCOLUMNNAME method for each column that is a primary or a foreign key.

  • access: private
void _createGetByMethods ()
_createGetIsValidMethodNameMethod (line 3320)

Creates just one method: getIsValidMethodName.

  • access: private
void _createGetIsValidMethodNameMethod ()
_createGetLabelColumnMethod (line 3281)

Creates just one method: getLabelColumn.

  • access: private
void _createGetLabelColumnMethod ()
_createGetNextMethods (line 1701)

Calls generateGetNextMethod on all RSDEngineColumn objects stored in $this->columns.

If generateGetNextMethod returns a valid RSDEngineMethod object addMethod is called with the RSDEngineMethod object as argument.

void _createGetNextMethods ()
_createGetSmartyHTMLOptionsArrayMethod (line 3299)

Creates just one method: getSmartyHTMLOptionsArray.

  • access: private
void _createGetSmartyHTMLOptionsArrayMethod ()
_createGetStoredMethods (line 1680)

Calls generateGetStoredMethod on all RSDEngineColumn objects stored in $this->columns.

If generateGetStoredMethod returns a valid RSDEngineMethod object addMethod is called with the RSDEngineMethod object as argument.

void _createGetStoredMethods ()
_createInsertMethod (line 1786)

Creates the method 'insert';

  • access: private
void _createInsertMethod ()
_createIsValidMethods (line 1568)

Calls generateIsValidMethod on all RSDEngineColumn objects stored in $this->columns.

void _createIsValidMethods ()
_createParseOptionsMethod (line 3356)

Creates the method '_parseOptions'.

  • access: private
void _createParseOptionsMethod ()
_createRemoveStoredMethods (line 1658)

Calls generateRemoveStoredMethod on all RSDEngineColumn objects stored in $this->columns.

If generateRemoveStoredMethod returns a valid RSDEngineMethod object addMethod is called with the RSDEngineMethod object as argument.

void _createRemoveStoredMethods ()
_createSelectMethod (line 2269)

Creates the method 'select';

  • access: private
void _createSelectMethod ()
_createStoreUploadedMethods (line 1636)

Calls generateStoreUploadedMethod on all RSDEngineColumn objects stored in $this->columns.

If generateStoreUploadedMethod returns a valid RSDEngineMethod object addMethod is called with the RSDEngineMethod object as argument.

void _createStoreUploadedMethods ()
_createUpdateByMethods (line 3195)

Creates a updateByCOLUMNNAME method for each column that is a primary or a foreign key.

  • access: private
void _createUpdateByMethods ()
_createUpdateMethod (line 1927)

Creates the method 'update';

  • access: private
void _createUpdateMethod ()
_getCommaSeperatedListOfColumnNames (line 3125)

Returns a string with all column names seperated by ", ".

  • return: Comma-seperated list of all column names.
  • access: private
String _getCommaSeperatedListOfColumnNames ()
_getCommaSeperatedListOfColumnNamesForVariableNames (line 3145)

Returns a string with all column names formatted for use as identifyers and prefixd with '$', seperated by ', ' and optionally quoted.

To put single quotes around the identifieyers pass the boolean value true as argument. The method getColumnNameForVariableName is called on every column.

  • return: Comma-seperated list of all column names formatted for use as identifyers and prefixed with the dollar sign.
  • access: private
String _getCommaSeperatedListOfColumnNamesForVariableNames ([boolean $quoted = false])
  • boolean $quoted: If true the column names get surrounded by single quotes. This argument is optional. The default is false.
_getConstructorMethod (line 3336)

Creates just one method: the constructor.

  • access: private
void _getConstructorMethod ()
_getFileOption (line 1391)

Returns the requested RSDEngineFileOption instance or the boolean value false if non-existing.

mixed &_getFileOption (String $type)
  • String $type: The type of the file option.
_getFileOptionDefaultProperty (line 1400)
void _getFileOptionDefaultProperty (mixed $fileType, mixed $propertyName)
_getSelectIncludingMethodName (line 3396)

Returns the name of the selectIncluding method that performs a join at least over all tables saved in $tableNames.

This method tries to find the method performing the smalles join in which all elements of $tableNames are involved. This method can be called with a string argument:


1 $this->_getSelectIncludingMethodName('prj_mytable');
Or if you need multiple tables to be involved in the join:

1 $this->_getSelectIncludingMethodName(array('prj_mytable', 'prj_mytable2'));

  • return: The method name or an empty string on failure.
  • access: private
mixed _getSelectIncludingMethodName (mixed $tableNames)
  • mixed $tableNames: The name of a table or multiple table names in an array.
_parse (line 385)

Parses the SQL DDL stored in $this->contents.

The method _parseBodyLine($bodyLine) gets called for each line.

boolean _parse ()
_parseAfterDeleteTableOption (line 554)

Parses the afterDelete table option saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseAfterDeleteTableOption ()
_parseAfterInsertTableOption (line 490)

Parses the afterInsert table option saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseAfterInsertTableOption ()
_parseAfterUpdateTableOption (line 522)

Parses the afterUpdate table option saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseAfterUpdateTableOption ()
_parseBeforeDeleteTableOption (line 538)

Parses the beforeDelete table option saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseBeforeDeleteTableOption ()
_parseBeforeInsertTableOption (line 474)

Parses the beforeInsert table option saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseBeforeInsertTableOption ()
_parseBeforeUpdateTableOption (line 506)

Parses the beforeUpdate table option saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseBeforeUpdateTableOption ()
_parseBodyLine (line 975)

Parses on line of SQL-Code.

If a column definition is found a new instance of RSDEngineColumn is created an stored in the associativ array columns. If a foreign key is found a new instance of RSDRelation is created an stored in the array relations. This method is called by the method _parse().

nothing _parseBodyLine (mixed $bodyLine)
_parseExcludeSelectMethodTableOptions (line 939)

Parses the excludeSelectMethod table options saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseExcludeSelectMethodTableOptions ()
_parseFileTableOptions (line 605)

Parses the file table options saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseFileTableOptions ()
_parseIncludeSelectMethodTableOptions (line 906)

Parses the includeSelectMethod table options saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseIncludeSelectMethodTableOptions ()
_parseLabelTableOption (line 570)

Parses the file table options saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseLabelTableOption ()
_parseLiveUserRightTableOptions (line 766)

Parses the LiveUserEdit table options saved in $this->tableOptions.

Gets called by RSDEngineDBTable::parseTableOptions.

  • access: private
void _parseLiveUserRightTableOptions ()
_setLiveUserRightSelectIncludingMethodName (line 324)

Sets the property selectIncludingMethod for all LiveUserRight instances.

This method is called in RSDEngineDBTable::createKeyMethods. The property selectIncludingMethod cannot be set earlier because the selectIncluding* methods must be generated first.

  • access: private
void _setLiveUserRightSelectIncludingMethodName ()

Documentation generated on Mon, 8 Dec 2003 13:12:19 +0100 by phpDocumentor 1.2.3