1: <?php
2:
3: namespace PHPixie\Database\Driver\Mongo;
4:
5: class Result extends \PHPixie\Database\Result
6: {
7: protected $cursor;
8:
9: public function __construct($cursor)
10: {
11: $this->cursor = $cursor;
12: }
13:
14: public function current()
15: {
16: if (!$this->cursor->valid())
17: return null;
18: $current = (object) $this->cursor->current();
19: $current->{'_id'} = (string) $current->{'_id'};
20: return $current;
21: }
22:
23: public function key()
24: {
25: if (!$this->cursor->valid())
26: return null;
27:
28: return $this->cursor->key();
29: }
30:
31: public function valid()
32: {
33: return $this->cursor->valid();
34: }
35:
36: public function next()
37: {
38: if($this->cursor->valid())
39: $this->cursor->next();
40: }
41:
42: public function rewind()
43: {
44: $this->cursor->rewind();
45: }
46:
47: public function cursor()
48: {
49: return $this->cursor;
50: }
51:
52: public function getItemField($item, $field)
53: {
54: $path = explode('.', $field);
55: $last = count($path) - 1;
56: $current = (array) $item;
57:
58: foreach ($path as $key => $step) {
59: if(!array_key_exists($step, $current))
60: return null;
61: $current=$current[$step];
62: }
63:
64: return $current;
65: }
66: }
67: