Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
DAOPreparedQueryAll.php
Go to the documentation of this file.
1<?php
2
4
10
20
21 protected function prepare(?DbCache $cache = null) {
22 $this->conditionParser->setCondition($this->condition);
23 parent::prepare($cache);
25 }
26
27 public function execute($params = [], $useCache = false) {
28 if ($useCache) {
29 $rows = $this->db->_optExecuteAndFetch($this->statement, $this->tableName, $this->preparedCondition, $params, $useCache);
30 } else {
31 $rows = $this->db->_optExecuteAndFetchNoCache($this->statement, $params);
32 }
33 if ($this->hasIncluded || !$this->allPublic) {
34 return $this->_parseQueryResponseWithIncluded($rows, $this->className, $useCache);
35 }
36 return $this->_parseQueryResponse($rows, $this->className);
37 }
38
39 protected function _parseQueryResponse($rows, $className) {
40 $objects = [];
41 if ($this->additionalMembers) {
42 foreach ($rows as $row) {
43 $object = DAO::_loadSimpleObjectFromRow($this->db, $row, $className, $this->memberList, $this->transformers);
44 $this->addAditionnalMembers($object, $row);
45 $objects[OrmUtils::getPropKeyValues($object, $this->propsKeys)] = $object;
46 }
47 } else {
48 foreach ($rows as $row) {
49 $object = DAO::_loadSimpleObjectFromRow($this->db, $row, $className, $this->memberList, $this->transformers);
50 $objects[OrmUtils::getPropKeyValues($object, $this->propsKeys)] = $object;
51 }
52 }
53 EventsManager::trigger(DAOEvents::GET_ALL, $objects, $className);
54 return $objects;
55 }
56
58 $objects = [];
60
61 $oneToManyQueries = $manyToOneQueries = $manyToManyParsers = [];
62 foreach ($rows as $row) {
63 $object = DAO::_loadObjectFromRow($this->db, $row, $className, $invertedJoinColumns, $manyToOneQueries, $this->oneToManyFields, $this->manyToManyFields, $oneToManyQueries, $manyToManyParsers, $this->memberList, $this->accessors, $this->transformers, $this->primaryKeys);
64 $key = OrmUtils::getPropKeyValues($object, $this->propsKeys);
65 if ($this->additionalMembers) {
66 $this->addAditionnalMembers($object, $row);
67 }
68 $objects[$key] = $object;
69 }
70 DAO::_affectsRelationObjects($className, $this->firstPropKey, $manyToOneQueries, $oneToManyQueries, $manyToManyParsers, $objects, $this->included, $useCache);
71 EventsManager::trigger(DAOEvents::GET_ALL, $objects, $className);
72 return $objects;
73 }
74}
Abstract class for database caching Ubiquity\cache\database$DbCache This class is part of Ubiquity.
Definition DbCache.php:20
DAO events constants.
Definition DAOEvents.php:14
Gateway class between database and object model.
Definition DAO.php:33
Object/relational mapping utilities.
Definition OrmUtils.php:17
static getPropKeyValues($instance, $props)
Definition OrmUtils.php:121
Ubiquity\orm\core\prepared$DAOPreparedQueryAll This class is part of Ubiquity.
_parseQueryResponseWithIncluded($rows, $className, $useCache)
Ubiquity\orm\core\prepared$DAOPreparedQuery This class is part of Ubiquity.
static _loadObjectFromRow(Database $db, $row, $className, $invertedJoinColumns, &$manyToOneQueries, $oneToManyFields, $manyToManyFields, &$oneToManyQueries, &$manyToManyParsers, $memberNames, $accessors, $transformers, $primaryKeys)
static _loadSimpleObjectFromRow(Database $db, $row, $className, $memberNames, $transformers)
static _affectsRelationObjects($className, $classPropKey, $manyToOneQueries, $oneToManyQueries, $manyToManyParsers, $objects, $included, $useCache)