AbstractRDBMapper.php
105 self::$dbEvents->attach(EventFeatureEventsInterface::EVENT_POST_INSERT, [$this, 'handleDbEvent']);
106 self::$dbEvents->attach(EventFeatureEventsInterface::EVENT_POST_UPDATE, [$this, 'handleDbEvent']);
107 self::$dbEvents->attach(EventFeatureEventsInterface::EVENT_POST_DELETE, [$this, 'handleDbEvent']);
171 * @param $strict Boolean indicating if the mapper must be an instance of RDBMapper (default true)
195 $this->isFileDB = $dbType == 'sqlite' && strtolower($this->connectionParams['dbName']) != ':memory:';
197 $this->connId = join(',', [$this->connectionParams['dbType'], $this->connectionParams['dbHostName'],
198 $this->connectionParams['dbUserName'], $this->connectionParams['dbPassword'], $this->connectionParams['dbName'],
199 // make sure that the sequence mapper uses it's own connection for separate transaction management
225 $this->connectionParams['dbName'] = FileUtil::realpath(WCMF_BASE.$this->connectionParams['dbName']);
366 * @param $parameters An associative array of parameter name/values pairs to replace the placeholders with (optional, default: empty array)
367 * @return If the query is a select, an array of associative arrays containing the selected data,
385 self::$logger->error("The query: ".$sql."\ncaused the following exception:\n".$ex->getMessage());
422 self::$logger->error("The query: ".$selectStmt->__toString()."\ncaused the following exception:\n".$ex->getMessage());
476 self::$logger->error("The operation: ".$operation."\ncaused the following exception:\n".$ex->getMessage());
505 throw new PersistenceException("No relation to '".$roleName."' exists in '".$this->getType()."'");
635 public function renderCriteria(Criteria $criteria, $placeholder=null, $tableName=null, $columnName=null) {
708 if ($buildDepth != BuildDepth::REQUIRED && $buildDepth != BuildDepth::SINGLE && $buildDepth > 0) {
720 ($buildDepth == BuildDepth::REQUIRED && $curRelationDesc->getOtherMinMultiplicity() > 0 && $curRelationDesc->getOtherAggregationKind() != 'none')
724 $childObject = $this->persistenceFacade->create($curRelationDesc->getOtherType(), BuildDepth::SINGLE);
727 $childObject = $this->persistenceFacade->create($curRelationDesc->getOtherType(), $newBuildDepth);
844 protected function getOIDsImpl($type, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) {
867 protected function loadObjectsImpl($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) {
871 $objects = $this->loadObjectsFromQueryParts($type, $buildDepth, $criteria, $orderby, $pagingInfo);
878 * @param $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build
880 * @param $criteria An array of Criteria instances that define conditions on the type's attributes (optional, default: _null_)
881 * @param $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (optional, default: _null_)
885 protected function loadObjectsFromQueryParts($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) {
900 public function loadObjectsFromSQL(SelectStatement $selectStmt, $buildDepth=BuildDepth::SINGLE, PagingInfo $pagingInfo=null,
947 * @param $data An associative array with the attribute names as keys and the attribute values as values
1003 if ($buildDepth != BuildDepth::SINGLE && $buildDepth != BuildDepth::INFINITE && $buildDepth > 0) {
1006 $loadNextGeneration = (($buildDepth != BuildDepth::SINGLE) && ($buildDepth > 0 || $buildDepth == BuildDepth::INFINITE));
1022 $object->setValue($role, isset($relatives[$oidStr]) ? $relatives[$oidStr] : null, true, false);
1062 list($selectStmt, $objValueName, $relValueName) = $otherMapper->getRelationSelectSQL($objects, $thisRole, $criteria, $orderby, $pagingInfo);
1064 $relatedObjects = $otherMapper->loadObjectsFromSQL($selectStmt, ($buildDepth == BuildDepth::PROXIES_ONLY) ? BuildDepth::SINGLE : $buildDepth, $pagingInfo, $originalData);
1070 // NOTE: we take the key from the original data, because the corresponding values in the objects might be
1102 $this->statements[] = [$statement->getSql(), $statement->getParameterContainer()->getNamedArray()];
1158 * This method an array of arrays with the first item being the sql string and the second the bind parameter array
1177 return isset(self::$inTransaction[$this->connId]) && self::$inTransaction[$this->connId] === true;
1186 * Get the names of the attributes in the mapped class to order by default and the sort directions
1187 * (ASC or DESC). The roleName parameter allows to ask for the order with respect to a specific role.
1189 * @return An array of assciative arrays with the keys sortFieldName and sortDirection (ASC or DESC)
1195 * @return An associative array with the relation names as keys and the RelationDescription instances as values.
1201 * @return An associative array with the attribute names as keys and the AttributeDescription instances as values.
1215 * @note The object does not have the final object id set. If a new id value for a primary key column is needed.
1216 * @note The prepared object will be used in the application afterwards. So values that are only to be modified for
1224 * @param $criteria An array of Criteria instances that define conditions on the type's attributes (optional, default: _null_)
1226 * @param $attributes An array holding names of attributes to select (optional, default: _null_)
1227 * @param $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (optional, default: _null_)
1228 * @param $pagingInfo An PagingInfo instance describing which page to load (optional, default: _null_))
1229 * @param $queryId Identifier for the query cache (maybe null to let implementers handle it). (default: _null_)
1230 * @return SelectStatement instance that selects all object data that match the condition or an array with the query parts.
1231 * @note The names of the data item columns MUST match the data item names provided in the '_datadef' array from RDBMapper::getObjectDefinition()
1232 * Use alias names if not! The selected data will be put into the '_data' array of the object definition.
1234 abstract public function getSelectSQL($criteria=null, $alias=null, $attributes=null, $orderby=null, PagingInfo $pagingInfo=null, $queryId=null);
1237 * Get the SQL command to select those objects from the database that are related to the given object.
1240 * @param $otherObjectProxies Array of PersistentObjectProxy instances for the objects to load the relatives for.
1242 * @param $criteria An array of Criteria instances that define conditions on the object's attributes (optional, default: _null_)
1243 * @param $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (optional, default: _null_)
1244 * @param $pagingInfo An PagingInfo instance describing which page to load (optional, default: _null_)
setIsInTransaction($isInTransaction)
Set the transaction state for the connection.
Definition: AbstractRDBMapper.php:1168
convertValueFromStorage($valueName, $value)
Convert value after retrieval from storage.
Definition: AbstractRDBMapper.php:982
RDBMapper defines the interface for mapper classes that map to relational databases.
Definition: RDBMapper.php:24
executeOperation(PersistenceOperation $operation)
Definition: AbstractRDBMapper.php:430
DeleteOperation holds data necessary to accomplish an delete operation on the persistent store.
Definition: DeleteOperation.php:21
AbstractRDBMapper maps objects of one type to a relational database schema.
Definition: AbstractRDBMapper.php:52
$persistenceFacade
Definition: AbstractMapper.php:50
loadObjects($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
Definition: AbstractMapper.php:325
wCMF - wemove Content Management Framework Copyright (C) 2005-2020 wemove digital solutions GmbH
Definition: AbstractRDBMapper.php:11
handleDbEvent($e)
Handle an event triggered from the laminas db layer.
Definition: AbstractRDBMapper.php:1099
A PersistenceOperation instance holds data necessary to accomplish an operation on the persistent sto...
Definition: PersistenceOperation.php:21
InsertOperation holds data necessary to accomplish an insert operation on the persistent store.
Definition: InsertOperation.php:21
EventManager is responsible for dispatching events to registered listeners.
Definition: EventManager.php:21
Instances of RDBManyToManyRelationDescription describe a many to many relation from 'this' end to 'ot...
Definition: RDBManyToManyRelationDescription.php:26
getRelations($hierarchyType='all')
Definition: AbstractRDBMapper.php:485
static getMapper($type, $strict=true)
Get the mapper for a Node and optionally check if it is a supported one.
Definition: AbstractRDBMapper.php:174
createObject(ObjectId $oid=null)
Factory method for the supported object type.
getUpdateSQL(PersistentObject $object)
Get the SQL command to update a object in the database.
loadObjectsFromSQL(SelectStatement $selectStmt, $buildDepth=BuildDepth::SINGLE, PagingInfo $pagingInfo=null, &$originalData=null)
Definition: AbstractRDBMapper.php:900
__construct(PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ConcurrencyManager $concurrencyManager, EventManager $eventManager)
Constructor.
Definition: AbstractRDBMapper.php:92
hasRelation($roleName)
Definition: AbstractMapper.php:100
UpdateOperation instances hold data necessary to accomplish an update operation on the persistent sto...
Definition: UpdateOperation.php:21
getType()
Get the entity type that this mapper handles.
getDefaultOrder($roleName=null)
Definition: AbstractRDBMapper.php:586
PersistenceException signals an exception in the persistence service.
Definition: PersistenceException.php:18
logAction(PersistentObject $obj)
Log the state of the given object.
Definition: AbstractMapper.php:381
getTableName()
Get the name of the database table, where this type is mapped to.
getSortkey($roleName=null)
Definition: AbstractRDBMapper.php:575
select(SelectStatement $selectStmt, PagingInfo $pagingInfo=null)
Definition: AbstractRDBMapper.php:393
getDeleteSQL(ObjectId $oid)
Get the SQL command to delete a object from the database.
createPKCondition(ObjectId $oid)
Create an array of condition Criteria instances for the primary key values.
getAttribute($name)
Definition: AbstractMapper.php:137
getPkNames()
Get the names of the primary key values.
const STATE_DELETED
Definition: PersistentObject.php:28
IllegalArgumentException signals an exception in method arguments.
Definition: IllegalArgumentException.php:18
getRelation($roleName)
Definition: AbstractMapper.php:108
PersistenceMapper defines the interface for all mapper classes.
Definition: PersistenceMapper.php:26
renderCriteria(Criteria $criteria, $placeholder=null, $tableName=null, $columnName=null)
Definition: AbstractRDBMapper.php:635
getStatements()
Definition: AbstractRDBMapper.php:1160
setState($state)
Set the state of the object to one of the STATE constants.
getAdapter()
Definition: AbstractRDBMapper.php:161
prepareForStorage(PersistentObject $object)
Set the object primary key and foreign key values for storing the object in the database.
quoteValue($value)
Definition: AbstractRDBMapper.php:349
removeValue($name)
Definition: PersistentObjectProxy.php:276
isForeignKey($name)
Determine if an attribute is a foreign key.
Criteria defines a condition on a PersistentObject's attribute used to select specific instances.
Definition: Criteria.php:21
isInTransaction()
Check if the connection is currently in a transaction.
Definition: AbstractRDBMapper.php:1176
ObjectId is the unique identifier of an object.
Definition: ObjectId.php:28
deleteImpl(PersistentObject $object)
Definition: AbstractRDBMapper.php:783
getRealTableName()
Definition: AbstractRDBMapper.php:359
BuildDepth values are used to define the depth when loading object trees.
Definition: BuildDepth.php:19
beginTransaction()
Definition: AbstractRDBMapper.php:1112
$permissionManager
Definition: AbstractMapper.php:51
rollbackTransaction()
Definition: AbstractRDBMapper.php:1146
loadObjectsImpl($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
Definition: AbstractRDBMapper.php:867
getOwnDefaultOrder($roleName=null)
TEMPLATE METHODS Subclasses must implement this method to define their object type.
PersistenceFacade defines the interface for PersistenceFacade implementations.
Definition: PersistenceFacade.php:23
loadImpl(ObjectId $oid, $buildDepth=BuildDepth::SINGLE)
Definition: AbstractRDBMapper.php:679
createObjectFromData(array $data)
Create an object of the mapper's type with the given attributes from the given data.
Definition: AbstractRDBMapper.php:950
loadObjectsFromQueryParts($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
Load objects defined by several query parts.
Definition: AbstractRDBMapper.php:885
ConcurrencyManager is used to handle concurrency for objects.
Definition: ConcurrencyManager.php:32
saveImpl(PersistentObject $object)
Definition: AbstractRDBMapper.php:739
createImpl($type, $buildDepth=BuildDepth::SINGLE)
Definition: AbstractRDBMapper.php:699
getAttributeDescriptions()
Get a list of all AttributeDescriptions.
constructOID($data)
Definition: AbstractRDBMapper.php:623
getType()
Get the type of PersistentObject on which the operation should be executed.
Definition: PersistenceOperation.php:45
FileUtil provides basic support for file functionality like HTTP file upload.
Definition: FileUtil.php:22
loadRelation(array $objects, $role, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
Definition: AbstractMapper.php:351
static getInstance($name, $dynamicConfiguration=[])
Definition: ObjectFactory.php:47
getRelationSelectSQL(array $otherObjectProxies, $otherRole, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
Get the SQL command to select those objects from the database that are related to the given object.
getAttributes(array $tags=[], $matchMode='all')
Definition: AbstractRDBMapper.php:540
const STATE_CLEAN
Definition: PersistentObject.php:25
AbstractMapper provides a basic implementation for other mapper classes.
Definition: AbstractMapper.php:41
quoteIdentifier($identifier)
Definition: AbstractRDBMapper.php:339
hasAttribute($name)
Definition: AbstractMapper.php:129
PersistentObjectProxy is proxy for an PersistentObject instance.
Definition: PersistentObjectProxy.php:24
getSelectSQL($criteria=null, $alias=null, $attributes=null, $orderby=null, PagingInfo $pagingInfo=null, $queryId=null)
Get the SQL command to select object data from the database.
getOIDsImpl($type, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
Definition: AbstractRDBMapper.php:844
getQuoteIdentifierSymbol()
Definition: AbstractRDBMapper.php:329
PagingInfo contains information about a paged list.
Definition: PagingInfo.php:18
PersistentObject defines the interface of all persistent objects.
Definition: PersistentObject.php:23
commitTransaction()
Definition: AbstractRDBMapper.php:1129
addRelatedObjects(array $objects, $buildDepth=BuildDepth::SINGLE)
Append the child data to a list of object.
Definition: AbstractRDBMapper.php:1000
PermissionManager implementations are used to handle all authorization requests.
Definition: PermissionManager.php:20
executeSql($sql, $parameters=[])
Execute a query on the connection.
Definition: AbstractRDBMapper.php:370
isSortable($roleName=null)
Definition: AbstractRDBMapper.php:568
LogManager is used to retrieve Logger instances.
Definition: LogManager.php:20
$concurrencyManager
Definition: AbstractMapper.php:52
static realpath($path)
Realpath function that also works for non existing paths code from http://www.php....
Definition: FileUtil.php:244
getInsertSQL(PersistentObject $object)
Get the SQL command to insert a object into the database.
const INTERNAL_VALUE_PREFIX
Definition: AbstractRDBMapper.php:83
getConnection()
Definition: AbstractRDBMapper.php:151
loadRelationImpl(array $objects, $role, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null)
Definition: AbstractRDBMapper.php:1042
ObjectFactory implements the service locator pattern by wrapping a Factory instance and providing sta...
Definition: ObjectFactory.php:24
const SEQUENCE_CLASS
Definition: AbstractRDBMapper.php:54
getRelationIncludingNM($roleName)
Implementation of PersistenceMapper::getRelation() including nm classes in many to many relations.
Definition: AbstractRDBMapper.php:496
const STATE_DIRTY
Definition: PersistentObject.php:26
getOperator()
Get the comparison operator used to compare the given value with the attribute's value.
Definition: Criteria.php:108
getRelationDescriptions()
Get a list of all RelationDescriptions.
$eventManager
Definition: AbstractMapper.php:53