1 | <?php |
||
10 | class FetchIterator implements \Iterator, \ArrayAccess |
||
11 | { |
||
12 | /** |
||
13 | * @var mixed |
||
14 | */ |
||
15 | private $statement; |
||
16 | |||
17 | /** |
||
18 | * @var DbInterface |
||
19 | */ |
||
20 | private $dbInterface; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $current; |
||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $params = array(); |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | private $row = 0; |
||
35 | |||
36 | /** |
||
37 | * @param mixed $statement |
||
38 | * @param DbInterface $dbInterface |
||
39 | * @param array $params |
||
40 | */ |
||
41 | 8 | public function __construct($statement, DbInterface $dbInterface, array $params = array()) |
|
45 | |||
46 | /** |
||
47 | * Define params for the prepared statement |
||
48 | * @param array $params |
||
49 | * @return $this |
||
50 | */ |
||
51 | 8 | public function setParams(array $params = array()) |
|
56 | |||
57 | /** |
||
58 | * @param mixed $statement |
||
59 | * @return $this |
||
60 | */ |
||
61 | 8 | public function setStatement($statement) |
|
66 | |||
67 | /** |
||
68 | * @return mixed|\PDOStatement |
||
69 | */ |
||
70 | 5 | public function getStatement() |
|
74 | |||
75 | /** |
||
76 | * @return DbInterface |
||
77 | */ |
||
78 | 5 | public function getDbInterface() |
|
82 | |||
83 | /** |
||
84 | * @param DbInterface $dbInterface |
||
85 | * @return $this |
||
86 | */ |
||
87 | 8 | public function setDbInterface(DbInterface $dbInterface) |
|
92 | |||
93 | /** |
||
94 | * Return format depends on Fetch Mode |
||
95 | * @return array|object |
||
96 | */ |
||
97 | 4 | public function current() |
|
101 | |||
102 | /** |
||
103 | * @return void |
||
104 | */ |
||
105 | 1 | public function next() |
|
110 | |||
111 | /** |
||
112 | * @return bool |
||
113 | */ |
||
114 | 3 | public function valid() |
|
118 | |||
119 | 2 | public function rewind() |
|
125 | |||
126 | /** |
||
127 | * @return int |
||
128 | */ |
||
129 | 2 | public function key() |
|
133 | |||
134 | /** |
||
135 | * @param mixed $offset |
||
136 | * @return bool |
||
137 | */ |
||
138 | 1 | public function offsetExists($offset) |
|
143 | |||
144 | /** |
||
145 | * @param mixed $offset |
||
146 | * @return array|object |
||
147 | */ |
||
148 | 1 | public function offsetGet($offset) |
|
152 | |||
153 | /** |
||
154 | * @param mixed $offset |
||
155 | * @param mixed $value |
||
156 | * @throws Exception |
||
157 | */ |
||
158 | 1 | public function offsetSet($offset, $value) |
|
162 | |||
163 | /** |
||
164 | * @param mixed $offset |
||
165 | * @throws Exception |
||
166 | */ |
||
167 | 1 | public function offsetUnset($offset) |
|
171 | |||
172 | /** |
||
173 | * @param int $offset |
||
174 | */ |
||
175 | 2 | protected function seek($offset) |
|
192 | } |
||
193 |