1 | <?php |
||
19 | abstract class AbstractResultSet implements ResultSetInterface |
||
20 | { |
||
21 | const TYPE_ARRAYOBJECT = 'arrayobject'; |
||
22 | const TYPE_ARRAY = 'array'; |
||
23 | |||
24 | /** |
||
25 | * Return type to use when returning an object from the set. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $returnType = self::TYPE_ARRAYOBJECT; |
||
30 | |||
31 | /** |
||
32 | * Allowed return types. |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $allowedReturnTypes = [ |
||
37 | self::TYPE_ARRAYOBJECT, |
||
38 | self::TYPE_ARRAY, |
||
39 | ]; |
||
40 | |||
41 | /** |
||
42 | * @var ArrayObject |
||
43 | */ |
||
44 | protected $arrayObjectPrototype = null; |
||
45 | |||
46 | /** |
||
47 | * @var ZFResultSet |
||
48 | */ |
||
49 | protected $zfResultSet; |
||
50 | |||
51 | /** |
||
52 | * @param ZFResultSet $resultSet |
||
53 | * @param string $returnType |
||
54 | */ |
||
55 | 40 | public function __construct($resultSet, $returnType = self::TYPE_ARRAYOBJECT) |
|
60 | |||
61 | /** |
||
62 | * Set the row object prototype. |
||
63 | * |
||
64 | * @param ArrayObject $arrayObjectPrototype |
||
65 | * |
||
66 | * @throws Exception\InvalidArgumentException |
||
67 | * |
||
68 | * @return AbstractResultSet |
||
69 | */ |
||
70 | public function setArrayObjectPrototype($arrayObjectPrototype) |
||
76 | |||
77 | /** |
||
78 | * Get the row object prototype. |
||
79 | * |
||
80 | * @return ArrayObject |
||
81 | */ |
||
82 | public function getArrayObjectPrototype() |
||
86 | |||
87 | /** |
||
88 | * Get the return type to use when returning objects from the set. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getReturnType() |
||
96 | |||
97 | /** |
||
98 | * @return AbstractResultSet |
||
99 | */ |
||
100 | public function buffer() |
||
106 | |||
107 | /** |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function isBuffered() |
||
114 | |||
115 | /** |
||
116 | * Get the data source used to create the result set. |
||
117 | * |
||
118 | * @return null|\Iterator |
||
119 | */ |
||
120 | public function getDataSource() |
||
124 | |||
125 | /** |
||
126 | * Retrieve count of fields in individual rows of the result set. |
||
127 | * |
||
128 | * @return int |
||
129 | */ |
||
130 | 1 | public function getFieldCount() |
|
134 | |||
135 | /** |
||
136 | * Iterator: move pointer to next item. |
||
137 | */ |
||
138 | 24 | public function next() |
|
142 | |||
143 | /** |
||
144 | * Iterator: retrieve current key. |
||
145 | * |
||
146 | * @return mixed |
||
147 | */ |
||
148 | 1 | public function key() |
|
152 | |||
153 | /** |
||
154 | * Iterator: get current item. |
||
155 | * |
||
156 | * @return array|\ArrayObject|null |
||
157 | */ |
||
158 | public function current() |
||
162 | |||
163 | /** |
||
164 | * Iterator: is pointer valid? |
||
165 | * |
||
166 | * @return bool |
||
167 | */ |
||
168 | public function valid() |
||
172 | |||
173 | /** |
||
174 | * Iterator: rewind. |
||
175 | */ |
||
176 | public function rewind() |
||
180 | |||
181 | /** |
||
182 | * Countable: return count of rows. |
||
183 | * |
||
184 | * @return int |
||
185 | */ |
||
186 | 38 | public function count() |
|
190 | |||
191 | /** |
||
192 | * Cast result set to array of arrays. |
||
193 | * |
||
194 | * @return array |
||
195 | * |
||
196 | * @throws Exception\RuntimeException if any row is not castable to an array |
||
197 | */ |
||
198 | public function toArray() |
||
202 | } |
||
203 |