Resultset.php
4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
namespace Phalcon\Mvc\Model {
/**
* Phalcon\Mvc\Model\Resultset
*
* This component allows to Phalcon\Mvc\Model returns large resulsets with the minimum memory consumption
* Resulsets can be traversed using a standard foreach or a while statement. If a resultset is serialized
* it will dump all the rows into a big array. Then unserialize will retrieve the rows as they were before
* serializing.
*
* <code>
*
* //Using a standard foreach
* $robots = Robots::find(array("type='virtual'", "order" => "name"));
* foreach ($robots as $robot) {
* echo $robot->name, "\n";
* }
*
* //Using a while
* $robots = Robots::find(array("type='virtual'", "order" => "name"));
* $robots->rewind();
* while ($robots->valid()) {
* $robot = $robots->current();
* echo $robot->name, "\n";
* $robots->next();
* }
* </code>
*
*/
abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \Traversable, \SeekableIterator, \Countable, \ArrayAccess, \Serializable {
const TYPE_RESULT_FULL = 0;
const TYPE_RESULT_PARTIAL = 1;
const HYDRATE_RECORDS = 0;
const HYDRATE_OBJECTS = 2;
const HYDRATE_ARRAYS = 1;
protected $_type;
protected $_result;
protected $_cache;
protected $_isFresh;
protected $_pointer;
protected $_count;
protected $_activeRow;
protected $_rows;
protected $_errorMessages;
protected $_hydrateMode;
/**
* Moves cursor to next row in the resultset
*
*/
public function next(){ }
/**
* Gets pointer number of active row in the resultset
*
* @return int
*/
public function key(){ }
/**
* Rewinds resultset to its beginning
*
*/
public function rewind(){ }
/**
* Changes internal pointer to a specific position in the resultset
*
* @param int $position
*/
public function seek($position){ }
/**
* Counts how many rows are in the resultset
*
* @return int
*/
public function count(){ }
/**
* Checks whether offset exists in the resultset
*
* @param int $index
* @return boolean
*/
public function offsetExists($index){ }
/**
* Gets row in a specific position of the resultset
*
* @param int $index
* @return \Phalcon\Mvc\ModelInterface
*/
public function offsetGet($index){ }
/**
* Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface
*
* @param int $index
* @param \Phalcon\Mvc\ModelInterface $value
*/
public function offsetSet($index, $value){ }
/**
* Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface
*
* @param int $offset
*/
public function offsetUnset($offset){ }
/**
* Returns the internal type of data retrieval that the resultset is using
*
* @return int
*/
public function getType(){ }
/**
* Get first row in the resultset
*
* @return \Phalcon\Mvc\ModelInterface
*/
public function getFirst(){ }
/**
* Get last row in the resultset
*
* @return \Phalcon\Mvc\ModelInterface
*/
public function getLast(){ }
/**
* Set if the resultset is fresh or an old one cached
*
* @param boolean $isFresh
* @return \Phalcon\Mvc\Model\Resultset
*/
public function setIsFresh($isFresh){ }
/**
* Tell if the resultset if fresh or an old one cached
*
* @return boolean
*/
public function isFresh(){ }
/**
* Sets the hydration mode in the resultset
*
* @param int $hydrateMode
* @return \Phalcon\Mvc\Model\Resultset
*/
public function setHydrateMode($hydrateMode){ }
/**
* Returns the current hydration mode
*
* @return int
*/
public function getHydrateMode(){ }
/**
* Returns the associated cache for the resultset
*
* @return \Phalcon\Cache\BackendInterface
*/
public function getCache(){ }
/**
* Returns current row in the resultset
*
* @return \Phalcon\Mvc\ModelInterface
*/
public function current(){ }
/**
* Returns the error messages produced by a batch operation
*
* @return \Phalcon\Mvc\Model\MessageInterface[]
*/
public function getMessages(){ }
/**
* Deletes every record in the resultset
*
* @param Closure $conditionCallback
* @return boolean
*/
public function delete($conditionCallback=null){ }
/**
* Filters a resultset returning only those the developer requires
*
*<code>
* $filtered = $robots->filter(function($robot){
* if ($robot->id < 3) {
* return $robot;
* }
* });
*</code>
*
* @param callback $filter
* @return \Phalcon\Mvc\Model[]
*/
public function filter($filter){ }
}
}