1: <?php
2:
3: namespace PHPixie\ORM\Steps\Step\Query;
4:
5: abstract class Result extends \PHPixie\ORM\Steps\Step\Query
6: implements \PHPixie\ORM\Steps\Result
7: {
8: protected $result;
9:
10: public function execute()
11: {
12: $this->result = $this->query->execute();
13:
14: if ($this->result === null)
15: throw new \PHPixie\ORM\Exception\Plan("Query did not return a result.");
16: }
17:
18: public function result()
19: {
20: if ($this->result === null)
21: throw new \PHPixie\ORM\Exception\Plan("This plan step has not been executed yet.");
22:
23: return $this->result;
24: }
25:
26: public function getField($field, $skipNulls = true)
27: {
28: $values = array();
29: $result = $this->result();
30: foreach($this as $item) {
31: $value = $result->getItemField($item, $field);
32: if ($value !== null || !$skipNulls) {
33: $values[] = $value;
34: }
35: }
36:
37: return $values;
38: }
39:
40: public function getFields($fields)
41: {
42: $data = array();
43: $result = $this->result();
44: foreach($this as $item){
45: $values = array();
46: foreach($fields as $field) {
47: $values[$field] = $result->getItemField($item, $field);
48: }
49: $data[]=$values;
50: }
51:
52: return $data;
53: }
54:
55: abstract public function getIterator();
56: abstract public function asArray();
57: }
58: