Detailed Description
RDBMapper maps objects of one type to a relational database schema.
It defines a persistence mechanism that specialized mappers customize by overriding the given template methods.
Definition at line 49 of file RDBMapper.php.
Public Member Functions | |
__construct (PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ConcurrencyManager $concurrencyManager, EventManager $eventManager, Message $message) | |
__sleep () | |
setConnectionParams ($params) | |
getConnectionParams () | |
enableProfiler () | |
disableProfiler () | |
getProfiler () | |
getQuoteIdentifierSymbol () | |
quoteIdentifier ($identifier) | |
quoteValue ($value) | |
getRealTableName () | |
executeSql ($sql, $isSelect=false, $bindValues=array()) | |
executeOperation (PersistenceOperation $operation) | |
getRelations ($hierarchyType='all') | |
getRelation ($roleName) | |
getRelationsByType ($type) | |
getAttributes (array $tags=array(), $matchMode='all') | |
getAttribute ($name) | |
isSortable ($roleName=null) | |
getSortkey ($roleName=null) | |
getDefaultOrder ($roleName=null) | |
renderCriteria (Criteria $criteria, $placeholder=null, $tableName=null, $columnName=null) | |
getConnection () | |
loadObjectsFromSQL (SelectStatement $selectStmt, $buildDepth=BuildDepth::SINGLE, PagingInfo $pagingInfo=null) | |
beginTransaction () | |
commitTransaction () | |
rollbackTransaction () | |
getSelectSQL ($criteria=null, $alias=null, $orderby=null, PagingInfo $pagingInfo=null, $queryId=null) | |
isForeignKey ($name) | |
Public Member Functions inherited from AbstractMapper | |
__construct (PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ConcurrencyManager $concurrencyManager, EventManager $eventManager, Message $message) | |
setLogStrategy (OutputStrategy $logStrategy) | |
hasRelation ($roleName) | |
hasAttribute ($name) | |
load (ObjectId $oid, $buildDepth=BuildDepth::SINGLE) | |
create ($type, $buildDepth=BuildDepth::SINGLE) | |
save (PersistentObject $object) | |
delete (PersistentObject $object) | |
getOIDs ($type, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
loadObjects ($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
loadRelation (array $objects, $role, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
Public Member Functions inherited from PersistenceMapper | |
getType () | |
getTypeDisplayName (Message $message) | |
getTypeDescription (Message $message) | |
getPkNames () | |
getAttributeDisplayName ($name, Message $message) | |
getAttributeDescription ($name, Message $message) | |
getProperties () | |
Public Attributes | |
const | INTERNAL_VALUE_PREFIX = '_mapper_internal_' |
Protected Member Functions | |
getNextId () | |
select (SelectStatement $selectStmt, PagingInfo $pagingInfo=null) | |
getRelationImpl ($roleName, $includeManyToMany) | |
getReferences () | |
isPkValue ($name) | |
constructOID ($data) | |
loadImpl (ObjectId $oid, $buildDepth=BuildDepth::SINGLE) | |
createImpl ($type, $buildDepth=BuildDepth::SINGLE) | |
saveImpl (PersistentObject $object) | |
deleteImpl (PersistentObject $object) | |
getOIDsImpl ($type, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
loadObjectsImpl ($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
loadObjectsFromQueryParts ($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
createObjectFromData (array $data) | |
applyDataOnLoad (PersistentObject $object, array $objectData) | |
applyDataOnCreate (PersistentObject $object) | |
addRelatedObjects (array $objects, $buildDepth=BuildDepth::SINGLE) | |
loadRelationImpl (array $objects, $role, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
setIsInTransaction ($isInTransaction) | |
isInTransaction () | |
getOwnDefaultOrder ($roleName=null) | |
getRelationDescriptions () | |
getAttributeDescriptions () | |
createObject (ObjectId $oid=null) | |
prepareForStorage (PersistentObject $object) | |
getRelationSelectSQL (array $otherObjectProxies, $otherRole, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
getInsertSQL (PersistentObject $object) | |
getUpdateSQL (PersistentObject $object) | |
getDeleteSQL (ObjectId $oid) | |
createPKCondition (ObjectId $oid) | |
getTableName () | |
Protected Member Functions inherited from AbstractMapper | |
logAction (PersistentObject $obj) | |
checkAuthorization ($resource, $action) | |
authorizationFailedError ($resource, $action) | |
loadImpl (ObjectId $oid, $buildDepth=BuildDepth::SINGLE) | |
createImpl ($type, $buildDepth=BuildDepth::SINGLE) | |
saveImpl (PersistentObject $object) | |
deleteImpl (PersistentObject $object) | |
getOIDsImpl ($type, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
loadObjectsImpl ($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
loadRelationImpl (array $objects, $role, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) | |
Additional Inherited Members | |
Protected Attributes inherited from AbstractMapper | |
$_persistenceFacade = null | |
$_permissionManager = null | |
$_concurrencyManager = null | |
$_eventManager = null | |
$_message = null | |
Constructor & Destructor Documentation
__construct | ( | PersistenceFacade | $persistenceFacade, |
PermissionManager | $permissionManager, | ||
ConcurrencyManager | $concurrencyManager, | ||
EventManager | $eventManager, | ||
Message | $message | ||
) |
Constructor.
- Parameters
-
$persistenceFacade $permissionManager $concurrencyManager $eventManager $message
Definition at line 83 of file RDBMapper.php.
Member Function Documentation
__sleep | ( | ) |
Select data to be stored in the session.
PDO throws an excetption if tried to be (un-)serialized.
Definition at line 100 of file RDBMapper.php.
setConnectionParams | ( | $params | ) |
Set the connection parameters.
- Parameters
-
$params Initialization data given in an assoziative array with the following keys: dbType, dbHostName, dbUserName, dbPassword, dbName if dbPrefix is given it will be appended to every table string, which is usefull if different cms operate on the same database
Definition at line 111 of file RDBMapper.php.
getConnectionParams | ( | ) |
Get the connection parameters.
- Returns
- Assoziative array with the following keys: dbType, dbHostName, dbUserName, dbPassword, dbName, dbPrefix
Definition at line 123 of file RDBMapper.php.
enableProfiler | ( | ) |
Enable profiling.
Definition at line 202 of file RDBMapper.php.
disableProfiler | ( | ) |
Disable profiling.
Definition at line 212 of file RDBMapper.php.
getProfiler | ( | ) |
|
protected |
Get a new id for inserting into the database.
- Returns
- An id value.
Definition at line 234 of file RDBMapper.php.
getQuoteIdentifierSymbol | ( | ) |
Implements PersistenceMapper.
Definition at line 275 of file RDBMapper.php.
quoteIdentifier | ( | $identifier | ) |
Implements PersistenceMapper.
Definition at line 285 of file RDBMapper.php.
quoteValue | ( | $value | ) |
- See also
- PersistenceMapper::quoteValue
Implements PersistenceMapper.
Definition at line 295 of file RDBMapper.php.
getRealTableName | ( | ) |
Get the table name with the dbprefix added.
- Returns
- The table name
Definition at line 306 of file RDBMapper.php.
executeSql | ( | $sql, | |
$isSelect = false , |
|||
$bindValues = array() |
|||
) |
Execute a query on the connection.
- Parameters
-
$sql The SQL statement as string $isSelect Boolean whether the statement is a select statement (optional, default: false) $bindValues An array of data to bind to the placeholders (optional, default: empty array)
- Returns
- If isSelect is true, an array as the result of PDOStatement::fetchAll(PDO::FETCH_ASSOC), the number of affected rows else
Definition at line 318 of file RDBMapper.php.
|
protected |
Execute a select query on the connection.
- Parameters
-
$selectStmt A SelectStatement instance $pagingInfo An PagingInfo instance describing which page to load (optional, default: null)
- Returns
- An array as the result of PDOStatement::fetchAll(PDO::FETCH_ASSOC)
Definition at line 346 of file RDBMapper.php.
executeOperation | ( | PersistenceOperation | $operation | ) |
Implements PersistenceMapper.
Definition at line 383 of file RDBMapper.php.
getRelations | ( | $hierarchyType = 'all' | ) |
Implements PersistenceMapper.
Definition at line 437 of file RDBMapper.php.
getRelation | ( | $roleName | ) |
- See also
- PersistenceMapper::getRelation()
Implements PersistenceMapper.
Definition at line 450 of file RDBMapper.php.
getRelationsByType | ( | $type | ) |
Implements PersistenceMapper.
Definition at line 457 of file RDBMapper.php.
|
protected |
Internal implementation of PersistenceMapper::getRelation()
- Parameters
-
$roleName The role name of the relation $includeManyToMany Boolean whether to also search in relations to many to many objects or not
- Returns
- RelationDescription
Definition at line 474 of file RDBMapper.php.
getAttributes | ( | array | $tags = array() , |
$matchMode = 'all' |
|||
) |
Implements PersistenceMapper.
Definition at line 530 of file RDBMapper.php.
getAttribute | ( | $name | ) |
Implements PersistenceMapper.
Definition at line 549 of file RDBMapper.php.
|
protected |
Get the references to other entities.
- Returns
- Array of AttributeDescription instances
Definition at line 563 of file RDBMapper.php.
isSortable | ( | $roleName = null | ) |
- See also
- PersistenceMapper::isSortable()
Implements PersistenceMapper.
Definition at line 587 of file RDBMapper.php.
getSortkey | ( | $roleName = null | ) |
- See also
- PersistenceMapper::getSortkey()
Implements PersistenceMapper.
Definition at line 594 of file RDBMapper.php.
getDefaultOrder | ( | $roleName = null | ) |
Implements PersistenceMapper.
Definition at line 605 of file RDBMapper.php.
|
protected |
Check if a value is a primary key value.
- Parameters
-
$name The name of the value
- Returns
- Boolean
Definition at line 634 of file RDBMapper.php.
|
protected |
Construct an object id from given row data.
- Parameters
-
$data An associative array with the pk column names as keys and pk values as values
- Returns
- The oid
Definition at line 644 of file RDBMapper.php.
renderCriteria | ( | Criteria | $criteria, |
$placeholder = null , |
|||
$tableName = null , |
|||
$columnName = null |
|||
) |
Render a Criteria instance as string.
- Parameters
-
$criteria The Criteria instance $placeholder Placeholder (':columnName', '?') used instead of the value (optional, default: null) $tableName The table name to use (may differ from criteria's type attribute) (optional) $columnName The column name to use (may differ from criteria's attribute attribute) (optional)
- Returns
- String
Definition at line 661 of file RDBMapper.php.
|
protected |
- See also
- AbstractMapper::loadImpl()
Definition at line 700 of file RDBMapper.php.
|
protected |
- See also
- AbstractMapper::createImpl()
- Note
- The type parameter is not used here because this class only constructs one type
Definition at line 720 of file RDBMapper.php.
|
protected |
- See also
- AbstractMapper::saveImpl()
Definition at line 760 of file RDBMapper.php.
|
protected |
- See also
- AbstractMapper::deleteImpl()
Definition at line 804 of file RDBMapper.php.
getConnection | ( | ) |
Get the database connection.
- Returns
- A reference to the PDOConnection object
Definition at line 865 of file RDBMapper.php.
|
protected |
- See also
- PersistenceMapper::getOIDsImpl()
- Note
- The type parameter is not used here because this class only constructs one type
Definition at line 876 of file RDBMapper.php.
|
protected |
- See also
- PersistenceFacade::loadObjectsImpl()
Definition at line 894 of file RDBMapper.php.
|
protected |
Load objects defined by several query parts.
- Parameters
-
$type The type of the object $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build (except BuildDepth::REQUIRED, BuildDepth::PROXIES_ONLY) (default: BuildDepth::SINGLE) $criteria An array of Criteria instances that define conditions on the type's attributes (optional, default: null) $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (optional, default: null) $pagingInfo A reference PagingInfo instance (optional, default: null)
- Returns
- Array of PersistentObject instances
Definition at line 912 of file RDBMapper.php.
loadObjectsFromSQL | ( | SelectStatement | $selectStmt, |
$buildDepth = BuildDepth::SINGLE , |
|||
PagingInfo | $pagingInfo = null |
||
) |
Load objects defined by a select statement.
- Parameters
-
$selectStmt A SelectStatement instance $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build (except BuildDepth::REQUIRED, BuildDepth::PROXIES_ONLY) (default: BuildDepth::SINGLE) $pagingInfo A reference PagingInfo instance (optional, default: null)
- Returns
- Array of PersistentObject instances
Definition at line 932 of file RDBMapper.php.
|
protected |
Create an object of the mapper's type with the given attributes from the given data.
- Parameters
-
$data An associative array with the attribute names as keys and the attribute values as values
- Returns
- PersistentObject
Definition at line 973 of file RDBMapper.php.
|
protected |
Apply the loaded object data to the object.
- Note
- Subclasses must implement this method to define their object type.
- Parameters
-
$object A reference to the object created with createObject method to which the data should be applied $objectData An associative array with the data returned by execution of the database select statement (given by getSelectSQL).
Definition at line 1003 of file RDBMapper.php.
|
protected |
Apply the default data to the object.
- Note
- Subclasses must implement this method to define their object type.
- Parameters
-
$object A reference to the object created with createObject method to which the data should be applied
Definition at line 1019 of file RDBMapper.php.
|
protected |
Append the child data to a list of object.
If the buildDepth does not determine to load a child generation, only the oids of the children will be loaded.
- Parameters
-
$objects Array of PersistentObject instances to append the children to $buildDepth
- See also
- PersistenceFacade::loadObjects()
Definition at line 1036 of file RDBMapper.php.
|
protected |
Definition at line 1079 of file RDBMapper.php.
beginTransaction | ( | ) |
- See also
- PersistenceMapper::beginTransaction() Since all RDBMapper instances with the same connection parameters share one connection, the call will be ignored, if the method was already called for another instance.
Implements PersistenceMapper.
Definition at line 1138 of file RDBMapper.php.
commitTransaction | ( | ) |
- See also
- PersistenceMapper::commitTransaction() Since all RDBMapper instances with the same connection parameters share one connection, the call will be ignored, if the method was already called for another instance.
Implements PersistenceMapper.
Definition at line 1154 of file RDBMapper.php.
rollbackTransaction | ( | ) |
- Note
- Rollbacks have to be supported by the database. Since all RDBMapper instances with the same connection parameters share one connection, the call will be ignored, if the method was already called for another instance.
Implements PersistenceMapper.
Definition at line 1171 of file RDBMapper.php.
|
protected |
Set the transaction state for the connection.
- Parameters
-
$isInTransaction Boolean whether the connection is in a transaction or not
Definition at line 1185 of file RDBMapper.php.
|
protected |
Check if the connection is currently in a transaction.
- Returns
- Boolean
Definition at line 1193 of file RDBMapper.php.
|
abstractprotected |
TEMPLATE METHODS Subclasses must implement this method to define their object type.
Get the names of the attributes in the mapped class to order by default and the sort directions (ASC or DESC). The roleName parameter allows to ask for the order with respect to a specific role.
- Parameters
-
$roleName The role name of the relation (optional, default: null)
- Returns
- An array of assciative arrays with the keys sortFieldName and sortDirection (ASC or DESC)
|
abstractprotected |
Get a list of all RelationDescriptions.
- Returns
- An associative array with the relation names as keys and the RelationDescription instances as values.
|
abstractprotected |
Get a list of all AttributeDescriptions.
- Returns
- An associative array with the attribute names as keys and the AttributeDescription instances as values.
|
abstractprotected |
Factory method for the supported object type.
- Parameters
-
$oid The object id (maybe null)
- Returns
- A reference to the created object.
|
abstractprotected |
Set the object primary key and foreign key values for storing the object in the database.
- Parameters
-
$object A reference to the object to insert.
- Note
- The object does not have the final object id set. If a new id value for a primary key column is needed.
- The prepared object will be used in the application afterwards. So values that are only to be modified for the storage process should be changed in getInsertSQL() and getUpdateSQL() only! for the insert statement, use RDBMapper::getNextId().
|
abstract |
Get the SQL command to select object data from the database.
- Parameters
-
$criteria An array of Criteria instances that define conditions on the type's attributes (optional, default: null) $alias The alias for the table name (default: null) $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (optional, default: null) $pagingInfo An PagingInfo instance describing which page to load (optional, default: null)) $queryId Identifier for the query cache (maybe null to let implementers handle it). (default: null)
- Returns
- SelectStatement instance that selects all object data that match the condition or an array with the query parts.
- Note
- The names of the data item columns MUST match the data item names provided in the '_datadef' array from RDBMapper::getObjectDefinition() Use alias names if not! The selected data will be put into the '_data' array of the object definition.
|
abstractprotected |
Get the SQL command to select those objects from the database that are related to the given object.
- Note
- Navigability may not be checked in this method
- In case of a sortable many to many relation, the sortkey value must also be selected
- Parameters
-
$otherObjectProxies Array of PersistentObjectProxy instances for the objects to load the relatives for. $otherRole The role of the other object in relation to the objects to load. $criteria An array of Criteria instances that define conditions on the object's attributes (optional, default: null) $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (optional, default: null) $pagingInfo An PagingInfo instance describing which page to load (optional, default: null)
- Returns
- Array with SelectStatement instance and the attribute names which establish the relation between the loaded objects and the proxies (proxies's attribute name first)
|
abstractprotected |
Get the SQL command to insert a object into the database.
- Parameters
-
$object A reference to the object to insert.
- Returns
- Array of PersistenceOperation instances that insert a new object.
|
abstractprotected |
Get the SQL command to update a object in the database.
- Parameters
-
$object A reference to the object to update.
- Returns
- Array of PersistenceOperation instances that update an existing object.
|
abstractprotected |
Get the SQL command to delete a object from the database.
- Parameters
-
$oid The object id of the object to delete.
- Returns
- Array of PersistenceOperation instances that delete an existing object.
|
abstractprotected |
Create an array of condition Criteria instances for the primary key values.
- Parameters
-
$oid The object id that defines the primary key values
- Returns
- Array of Criteria instances
|
abstractprotected |
Get the name of the database table, where this type is mapped to.
- Returns
- String
|
abstract |
Determine if an attribute is a foreign key.
- Returns
- Boolean
Member Data Documentation
const INTERNAL_VALUE_PREFIX = '_mapper_internal_' |
Definition at line 73 of file RDBMapper.php.