|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ubiquity\orm\core\prepared; |
|
4
|
|
|
|
|
5
|
|
|
use Ubiquity\db\SqlUtils; |
|
6
|
|
|
use Ubiquity\events\DAOEvents; |
|
7
|
|
|
use Ubiquity\events\EventsManager; |
|
8
|
|
|
use Ubiquity\orm\OrmUtils; |
|
9
|
|
|
use Ubiquity\orm\DAO; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Ubiquity\orm\core\prepared$DAOPreparedQueryOne |
|
13
|
|
|
* This class is part of Ubiquity |
|
14
|
|
|
* |
|
15
|
|
|
* @author jcheron <[email protected]> |
|
16
|
|
|
* @version 1.0.0 |
|
17
|
|
|
* |
|
18
|
|
|
*/ |
|
19
|
|
|
class DAOPreparedQueryAll extends DAOPreparedQuery { |
|
20
|
|
|
|
|
21
|
|
|
protected function prepare() { |
|
22
|
|
|
$this->conditionParser->setCondition ( $this->condition ); |
|
23
|
|
|
parent::prepare (); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function execute($params = [], $useCache = false) { |
|
27
|
|
|
$objects = array (); |
|
28
|
|
|
$invertedJoinColumns = null; |
|
29
|
|
|
|
|
30
|
|
|
$cp = $this->conditionParser; |
|
31
|
|
|
$cp->setParams ( $params ); |
|
32
|
|
|
$className = $this->className; |
|
33
|
|
|
$query = $this->db->prepareAndExecute ( $this->tableName, SqlUtils::checkWhere ( $cp->getCondition () ), $this->fieldList, $cp->getParams (), $useCache ); |
|
34
|
|
|
$oneToManyQueries = [ ]; |
|
35
|
|
|
$manyToOneQueries = [ ]; |
|
36
|
|
|
$manyToManyParsers = [ ]; |
|
37
|
|
|
foreach ( $query as $row ) { |
|
38
|
|
|
$object = DAO::_loadObjectFromRow ( $row, $className, $invertedJoinColumns, $manyToOneQueries, $this->oneToManyFields, $this->manyToManyFields, $oneToManyQueries, $manyToManyParsers, $this->accessors, $this->transformers ); |
|
39
|
|
|
$key = OrmUtils::getPropKeyValues ( $object, $this->propsKeys ); |
|
40
|
|
|
$objects [$key] = $object; |
|
41
|
|
|
} |
|
42
|
|
|
if ($this->hasIncluded) { |
|
43
|
|
|
DAO::_affectsRelationObjects ( $className, $this->firstPropKey, $manyToOneQueries, $oneToManyQueries, $manyToManyParsers, $objects, $this->included, $useCache ); |
|
44
|
|
|
} |
|
45
|
|
|
EventsManager::trigger ( DAOEvents::GET_ALL, $objects, $className ); |
|
46
|
|
|
return $objects; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|