1: <?php
2:
3: namespace PHPixie\ORM\Planners\Planner;
4:
5: class Update extends \PHPixie\ORM\Planners\Planner
6: {
7: protected $steps;
8:
9: public function __construct($steps)
10: {
11: $this->steps = $steps;
12: }
13:
14: public function result($updateQuery, $map, $resultStep, $plan)
15: {
16: $mapStep = $this->steps->updateMap($updateQuery, $map, $resultStep);
17: $plan->add($mapStep);
18: }
19:
20: public function subquery($updateQuery, $map, $subquery, $plan)
21: {
22: $fields = $this->requiredFields($map);
23: $subquery->fields($fields);
24: $resultStep = $this->steps->iteratorResult($subquery);
25: $plan->add($resultStep);
26: $this->result($updateQuery, $map, $resultStep, $plan);
27: }
28:
29: protected function requiredFields($map)
30: {
31: return array_values(array_unique($map));
32: }
33: }