Detailed Description
AbstractRDBMapper 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 52 of file AbstractRDBMapper.php.
Public Member Functions | |
__construct (PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ConcurrencyManager $concurrencyManager, EventManager $eventManager) | |
__destruct () | |
__sleep () | |
setConnectionParams ($params) | |
getConnectionParams () | |
getConnection () | |
getAdapter () | |
getQuoteIdentifierSymbol () | |
quoteIdentifier ($identifier) | |
quoteValue ($value) | |
getRealTableName () | |
executeSql ($sql, $parameters=[]) | |
select (SelectStatement $selectStmt, PagingInfo $pagingInfo=null) | |
executeOperation (PersistenceOperation $operation) | |
getRelations ($hierarchyType='all') | |
getAttributes (array $tags=[], $matchMode='all') | |
isSortable ($roleName=null) | |
getSortkey ($roleName=null) | |
getDefaultOrder ($roleName=null) | |
constructOID ($data) | |
renderCriteria (Criteria $criteria, $placeholder=null, $tableName=null, $columnName=null) | |
loadObjectsFromSQL (SelectStatement $selectStmt, $buildDepth=BuildDepth::SINGLE, PagingInfo $pagingInfo=null, &$originalData=null) | |
handleDbEvent ($e) | |
beginTransaction () | |
commitTransaction () | |
rollbackTransaction () | |
getStatements () | |
getSelectSQL ($criteria=null, $alias=null, $attributes=null, $orderby=null, PagingInfo $pagingInfo=null, $queryId=null) | |
isForeignKey ($name) | |
Public Member Functions inherited from AbstractMapper | |
setLogStrategy (OutputStrategy $logStrategy) | |
getTypeDisplayName (Message $message) | |
getTypeDescription (Message $message) | |
hasRelation ($roleName) | |
getRelation ($roleName) | |
getRelationsByType ($type) | |
hasAttribute ($name) | |
getAttribute ($name) | |
getReferences () | |
getAttributeDisplayName ($name, Message $message) | |
getAttributeDescription ($name, Message $message) | |
getProperties () | |
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 () | |
getPkNames () | |
Public Attributes | |
const | SEQUENCE_CLASS = 'DBSequence' |
const | INTERNAL_VALUE_PREFIX = '_mapper_internal_' |
Static Protected Member Functions | |
static | getMapper ($type, $strict=true) |
Additional Inherited Members | |
Protected Attributes inherited from AbstractMapper | |
$persistenceFacade = null | |
$permissionManager = null | |
$concurrencyManager = null | |
$eventManager = null | |
Constructor & Destructor Documentation
◆ __construct()
__construct | ( | PersistenceFacade | $persistenceFacade, |
PermissionManager | $permissionManager, | ||
ConcurrencyManager | $concurrencyManager, | ||
EventManager | $eventManager | ||
) |
Constructor.
- Parameters
-
$persistenceFacade $permissionManager $concurrencyManager $eventManager
Reimplemented from AbstractMapper.
Definition at line 92 of file AbstractRDBMapper.php.
◆ __destruct()
__destruct | ( | ) |
Destructor.
Definition at line 113 of file AbstractRDBMapper.php.
Member Function Documentation
◆ __sleep()
__sleep | ( | ) |
Select data to be stored in the session.
PDO throws an exception if tried to be (un-)serialized.
Definition at line 121 of file AbstractRDBMapper.php.
◆ setConnectionParams()
setConnectionParams | ( | $params | ) |
Set the connection parameters.
- Parameters
-
$params Initialization data given in an associative array with the following keys: dbType, dbHostName, dbUserName, dbPassword, dbName if dbPrefix is given it will be appended to every table string, which is useful if different applications operate on the same database
Definition at line 132 of file AbstractRDBMapper.php.
◆ getConnectionParams()
getConnectionParams | ( | ) |
Get the connection parameters.
- Returns
- Assoziative array with the following keys: dbType, dbHostName, dbUserName, dbPassword, dbName, dbPrefix
Definition at line 144 of file AbstractRDBMapper.php.
◆ getConnection()
getConnection | ( | ) |
- See also
- RDBMapper::getConnection()
Implements RDBMapper.
Definition at line 151 of file AbstractRDBMapper.php.
◆ getAdapter()
getAdapter | ( | ) |
- See also
- RDBMapper::getAdapter()
Implements RDBMapper.
Definition at line 161 of file AbstractRDBMapper.php.
◆ getMapper()
|
staticprotected |
◆ getSequenceMapper()
|
protected |
Get the sequence mapper.
- Returns
- PersistenceMapper
Definition at line 266 of file AbstractRDBMapper.php.
◆ getNextId()
|
protected |
Get a new id for inserting into the database.
- Returns
- An id value.
Definition at line 277 of file AbstractRDBMapper.php.
◆ getQuoteIdentifierSymbol()
getQuoteIdentifierSymbol | ( | ) |
Implements RDBMapper.
Definition at line 329 of file AbstractRDBMapper.php.
◆ quoteIdentifier()
quoteIdentifier | ( | $identifier | ) |
- See also
- RDBMapper::quoteIdentifier()
Implements RDBMapper.
Definition at line 339 of file AbstractRDBMapper.php.
◆ quoteValue()
quoteValue | ( | $value | ) |
- See also
- RDBMapper::quoteValue()
Implements RDBMapper.
Definition at line 349 of file AbstractRDBMapper.php.
◆ getRealTableName()
getRealTableName | ( | ) |
- See also
- RDBMapper::getRealTableName()
Implements RDBMapper.
Definition at line 359 of file AbstractRDBMapper.php.
◆ executeSql()
executeSql | ( | $sql, | |
$parameters = [] |
|||
) |
Execute a query on the connection.
- Parameters
-
$sql The SQL statement as string $parameters An associative array of parameter name/values pairs to replace the placeholders with (optional, default: empty array)
- Returns
- If the query is a select, an array of associative arrays containing the selected data, the number of affected rows else
Definition at line 370 of file AbstractRDBMapper.php.
◆ select()
select | ( | SelectStatement | $selectStmt, |
PagingInfo | $pagingInfo = null |
||
) |
- See also
- RDBMapper::select()
Implements RDBMapper.
Definition at line 393 of file AbstractRDBMapper.php.
◆ executeOperation()
executeOperation | ( | PersistenceOperation | $operation | ) |
Implements PersistenceMapper.
Definition at line 430 of file AbstractRDBMapper.php.
◆ getRelations()
getRelations | ( | $hierarchyType = 'all' | ) |
Implements PersistenceMapper.
Definition at line 485 of file AbstractRDBMapper.php.
◆ getRelationIncludingNM()
|
protected |
Implementation of PersistenceMapper::getRelation() including nm classes in many to many relations.
- Parameters
-
$roleName The role name of the relation
- Returns
- RelationDescription
Definition at line 496 of file AbstractRDBMapper.php.
◆ getAttributes()
getAttributes | ( | array | $tags = [] , |
$matchMode = 'all' |
|||
) |
Implements PersistenceMapper.
Definition at line 540 of file AbstractRDBMapper.php.
◆ isSortable()
isSortable | ( | $roleName = null | ) |
- See also
- PersistenceMapper::isSortable()
Implements PersistenceMapper.
Definition at line 568 of file AbstractRDBMapper.php.
◆ getSortkey()
getSortkey | ( | $roleName = null | ) |
- See also
- PersistenceMapper::getSortkey()
Implements PersistenceMapper.
Definition at line 575 of file AbstractRDBMapper.php.
◆ getDefaultOrder()
getDefaultOrder | ( | $roleName = null | ) |
Implements PersistenceMapper.
Definition at line 586 of file AbstractRDBMapper.php.
◆ isPkValue()
|
protected |
Check if a value is a primary key value.
- Parameters
-
$name The name of the value
- Returns
- Boolean
Definition at line 615 of file AbstractRDBMapper.php.
◆ constructOID()
constructOID | ( | $data | ) |
- See also
- RDBMapper::constructOID()
Implements RDBMapper.
Definition at line 623 of file AbstractRDBMapper.php.
◆ renderCriteria()
renderCriteria | ( | Criteria | $criteria, |
$placeholder = null , |
|||
$tableName = null , |
|||
$columnName = null |
|||
) |
- See also
- RDBMapper::renderCriteria()
Implements RDBMapper.
Definition at line 635 of file AbstractRDBMapper.php.
◆ loadImpl()
|
protected |
- See also
- AbstractMapper::loadImpl()
Reimplemented from AbstractMapper.
Definition at line 679 of file AbstractRDBMapper.php.
◆ createImpl()
|
protected |
- See also
- AbstractMapper::createImpl()
- Note
- The type parameter is not used here because this class only constructs one type
Reimplemented from AbstractMapper.
Definition at line 699 of file AbstractRDBMapper.php.
◆ saveImpl()
|
protected |
- See also
- AbstractMapper::saveImpl()
Reimplemented from AbstractMapper.
Definition at line 739 of file AbstractRDBMapper.php.
◆ deleteImpl()
|
protected |
- See also
- AbstractMapper::deleteImpl()
Reimplemented from AbstractMapper.
Definition at line 783 of file AbstractRDBMapper.php.
◆ getOIDsImpl()
|
protected |
- See also
- AbstractMapper::getOIDsImpl()
- Note
- The type parameter is not used here because this class only constructs one type
Reimplemented from AbstractMapper.
Definition at line 844 of file AbstractRDBMapper.php.
◆ loadObjectsImpl()
|
protected |
Reimplemented from AbstractMapper.
Definition at line 867 of file AbstractRDBMapper.php.
◆ loadObjectsFromQueryParts()
|
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 885 of file AbstractRDBMapper.php.
◆ loadObjectsFromSQL()
loadObjectsFromSQL | ( | SelectStatement | $selectStmt, |
$buildDepth = BuildDepth::SINGLE , |
|||
PagingInfo | $pagingInfo = null , |
||
& | $originalData = null |
||
) |
- See also
- RDBMapper::loadObjectsFromSQL()
Implements RDBMapper.
Definition at line 900 of file AbstractRDBMapper.php.
◆ createObjectFromData()
|
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 950 of file AbstractRDBMapper.php.
◆ convertValueFromStorage()
|
protected |
Convert value after retrieval from storage.
- Parameters
-
$valueName $value
- Returns
- Mixed
Definition at line 982 of file AbstractRDBMapper.php.
◆ addRelatedObjects()
|
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 1000 of file AbstractRDBMapper.php.
◆ loadRelationImpl()
|
protected |
Reimplemented from AbstractMapper.
Definition at line 1042 of file AbstractRDBMapper.php.
◆ handleDbEvent()
handleDbEvent | ( | $e | ) |
Handle an event triggered from the laminas db layer.
- Parameters
-
$e
Definition at line 1099 of file AbstractRDBMapper.php.
◆ beginTransaction()
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 1112 of file AbstractRDBMapper.php.
◆ commitTransaction()
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 1129 of file AbstractRDBMapper.php.
◆ rollbackTransaction()
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 1146 of file AbstractRDBMapper.php.
◆ getStatements()
getStatements | ( | ) |
- See also
- PersistenceMapper::getStatements() This method an array of arrays with the first item being the sql string and the second the bind parameter array
Implements PersistenceMapper.
Definition at line 1160 of file AbstractRDBMapper.php.
◆ setIsInTransaction()
|
protected |
Set the transaction state for the connection.
- Parameters
-
$isInTransaction Boolean whether the connection is in a transaction or not
Definition at line 1168 of file AbstractRDBMapper.php.
◆ isInTransaction()
|
protected |
Check if the connection is currently in a transaction.
- Returns
- Boolean
Definition at line 1176 of file AbstractRDBMapper.php.
◆ getOwnDefaultOrder()
|
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)
◆ getRelationDescriptions()
|
abstractprotected |
Get a list of all RelationDescriptions.
- Returns
- An associative array with the relation names as keys and the RelationDescription instances as values.
◆ getAttributeDescriptions()
|
abstractprotected |
Get a list of all AttributeDescriptions.
- Returns
- An associative array with the attribute names as keys and the AttributeDescription instances as values.
◆ createObject()
|
abstractprotected |
Factory method for the supported object type.
- Parameters
-
$oid The object id (maybe null)
- Returns
- PersitentObject
◆ prepareForStorage()
|
abstractprotected |
Set the object primary key and foreign key values for storing the object in the database.
- Parameters
-
$object PersistentObject instance 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().
Reimplemented in NodeUnifiedRDBMapper.
◆ getSelectSQL()
|
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) $attributes An array holding names of attributes to select (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)) $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.
Reimplemented in NodeUnifiedRDBMapper.
◆ getRelationSelectSQL()
|
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)
Reimplemented in NodeUnifiedRDBMapper.
◆ getInsertSQL()
|
abstractprotected |
Get the SQL command to insert a object into the database.
- Parameters
-
$object PersistentObject instance to insert.
- Returns
- Array of PersistenceOperation instances that insert a new object.
Reimplemented in NodeUnifiedRDBMapper.
◆ getUpdateSQL()
|
abstractprotected |
Get the SQL command to update a object in the database.
- Parameters
-
$object PersistentObject instance to update.
- Returns
- Array of PersistenceOperation instances that update an existing object.
Reimplemented in NodeUnifiedRDBMapper.
◆ getDeleteSQL()
|
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.
Reimplemented in NodeUnifiedRDBMapper.
◆ createPKCondition()
|
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
Reimplemented in NodeUnifiedRDBMapper.
◆ getTableName()
|
abstractprotected |
Get the name of the database table, where this type is mapped to.
- Returns
- String
◆ isForeignKey()
|
abstract |
Member Data Documentation
◆ SEQUENCE_CLASS
const SEQUENCE_CLASS = 'DBSequence' |
Definition at line 54 of file AbstractRDBMapper.php.
◆ INTERNAL_VALUE_PREFIX
const INTERNAL_VALUE_PREFIX = '_mapper_internal_' |
Definition at line 83 of file AbstractRDBMapper.php.