1 | <?php |
||
25 | class MongoCursor extends AbstractCursor implements Iterator |
||
1 ignored issue
–
show
|
|||
26 | { |
||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | public static $slaveOkay = false; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | public static $timeout = 30000; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $optionNames = [ |
||
41 | 'allowPartialResults', |
||
42 | 'batchSize', |
||
43 | 'cursorType', |
||
44 | 'limit', |
||
45 | 'maxTimeMS', |
||
46 | 'modifiers', |
||
47 | 'noCursorTimeout', |
||
48 | 'projection', |
||
49 | 'readPreference', |
||
50 | 'skip', |
||
51 | 'sort', |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $projection; |
||
58 | |||
59 | /** |
||
60 | * @var array |
||
61 | */ |
||
62 | protected $query; |
||
63 | |||
64 | protected $allowPartialResults; |
||
65 | protected $awaitData; |
||
66 | protected $flags; |
||
67 | protected $hint; |
||
68 | protected $limit; |
||
69 | protected $maxTimeMS; |
||
70 | protected $noCursorTimeout; |
||
71 | protected $options = []; |
||
72 | protected $skip; |
||
73 | protected $snapshot; |
||
74 | protected $sort; |
||
75 | protected $tailable; |
||
76 | |||
77 | /** |
||
78 | * Create a new cursor |
||
79 | * @link http://www.php.net/manual/en/mongocursor.construct.php |
||
80 | * @param MongoClient $connection Database connection. |
||
81 | * @param string $ns Full name of database and collection. |
||
82 | * @param array $query Database query. |
||
83 | * @param array $fields Fields to return. |
||
84 | */ |
||
85 | public function __construct(MongoClient $connection, $ns, array $query = array(), array $fields = array()) |
||
92 | |||
93 | /** |
||
94 | * Adds a top-level key/value pair to a query |
||
95 | * @link http://www.php.net/manual/en/mongocursor.addoption.php |
||
96 | * @param string $key Fieldname to add. |
||
97 | * @param mixed $value Value to add. |
||
98 | * @throws MongoCursorException |
||
99 | * @return MongoCursor Returns this cursor |
||
100 | */ |
||
101 | public function addOption($key, $value) |
||
108 | |||
109 | /** |
||
110 | * (PECL mongo >= 1.2.11)<br/> |
||
111 | * Sets whether this cursor will wait for a while for a tailable cursor to return more data |
||
112 | * @param bool $wait [optional] <p>If the cursor should wait for more data to become available.</p> |
||
113 | * @return MongoCursor Returns this cursor. |
||
114 | */ |
||
115 | public function awaitData($wait = true) |
||
122 | |||
123 | |||
124 | /** |
||
125 | * Counts the number of results for this query |
||
126 | * @link http://www.php.net/manual/en/mongocursor.count.php |
||
127 | * @param bool $foundOnly Send cursor limit and skip information to the count function, if applicable. |
||
128 | * @return int The number of documents returned by this cursor's query. |
||
129 | */ |
||
130 | public function count($foundOnly = false) |
||
146 | |||
147 | |||
148 | /** |
||
149 | * Execute the query |
||
150 | * @link http://www.php.net/manual/en/mongocursor.doquery.php |
||
151 | * @throws MongoConnectionException if it cannot reach the database. |
||
152 | * @return void |
||
153 | */ |
||
154 | protected function doQuery() |
||
160 | |||
161 | /** |
||
162 | * Return an explanation of the query, often useful for optimization and debugging |
||
163 | * @link http://www.php.net/manual/en/mongocursor.explain.php |
||
164 | * @return array Returns an explanation of the query. |
||
165 | */ |
||
166 | public function explain() |
||
170 | |||
171 | /** |
||
172 | * Sets the fields for a query |
||
173 | * @link http://www.php.net/manual/en/mongocursor.fields.php |
||
174 | * @param array $f Fields to return (or not return). |
||
175 | * @throws MongoCursorException |
||
176 | * @return MongoCursor |
||
177 | */ |
||
178 | public function fields(array $f) |
||
185 | |||
186 | /** |
||
187 | * Return the next object to which this cursor points, and advance the cursor |
||
188 | * @link http://www.php.net/manual/en/mongocursor.getnext.php |
||
189 | * @throws MongoConnectionException |
||
190 | * @throws MongoCursorTimeoutException |
||
191 | * @return array Returns the next object |
||
192 | */ |
||
193 | public function getNext() |
||
199 | |||
200 | /** |
||
201 | * Checks if there are any more elements in this cursor |
||
202 | * @link http://www.php.net/manual/en/mongocursor.hasnext.php |
||
203 | * @throws MongoConnectionException |
||
204 | * @throws MongoCursorTimeoutException |
||
205 | * @return bool Returns true if there is another element |
||
206 | */ |
||
207 | public function hasNext() |
||
212 | |||
213 | /** |
||
214 | * Gives the database a hint about the query |
||
215 | * @link http://www.php.net/manual/en/mongocursor.hint.php |
||
216 | * @param array|string $keyPattern Indexes to use for the query. |
||
217 | * @throws MongoCursorException |
||
218 | * @return MongoCursor Returns this cursor |
||
219 | */ |
||
220 | public function hint($keyPattern) |
||
227 | |||
228 | /** |
||
229 | * Sets whether this cursor will timeout |
||
230 | * @link http://www.php.net/manual/en/mongocursor.immortal.php |
||
231 | * @param bool $liveForever If the cursor should be immortal. |
||
232 | * @throws MongoCursorException |
||
233 | * @return MongoCursor Returns this cursor |
||
234 | */ |
||
235 | public function immortal($liveForever = true) |
||
242 | |||
243 | /** |
||
244 | * Limits the number of results returned |
||
245 | * @link http://www.php.net/manual/en/mongocursor.limit.php |
||
246 | * @param int $num The number of results to return. |
||
247 | * @throws MongoCursorException |
||
248 | * @return MongoCursor Returns this cursor |
||
249 | */ |
||
250 | public function limit($num) |
||
257 | |||
258 | /** |
||
259 | * @param int $ms |
||
260 | * @return $this |
||
261 | * @throws MongoCursorException |
||
262 | */ |
||
263 | public function maxTimeMS($ms) |
||
270 | |||
271 | /** |
||
272 | * @link http://www.php.net/manual/en/mongocursor.partial.php |
||
273 | * @param bool $okay [optional] <p>If receiving partial results is okay.</p> |
||
274 | * @return MongoCursor Returns this cursor. |
||
275 | */ |
||
276 | public function partial($okay = true) |
||
282 | |||
283 | /** |
||
284 | * Clears the cursor |
||
285 | * @link http://www.php.net/manual/en/mongocursor.reset.php |
||
286 | * @return void |
||
287 | */ |
||
288 | public function reset() |
||
292 | |||
293 | /** |
||
294 | * @link http://www.php.net/manual/en/mongocursor.setflag.php |
||
295 | * @param int $flag |
||
296 | * @param bool $set |
||
297 | * @return MongoCursor |
||
298 | */ |
||
299 | public function setFlag($flag, $set = true) |
||
303 | |||
304 | /** |
||
305 | * Skips a number of results |
||
306 | * @link http://www.php.net/manual/en/mongocursor.skip.php |
||
307 | * @param int $num The number of results to skip. |
||
308 | * @throws MongoCursorException |
||
309 | * @return MongoCursor Returns this cursor |
||
310 | */ |
||
311 | public function skip($num) |
||
318 | |||
319 | /** |
||
320 | * Sets whether this query can be done on a slave |
||
321 | * This method will override the static class variable slaveOkay. |
||
322 | * @link http://www.php.net/manual/en/mongocursor.slaveOkay.php |
||
323 | * @param boolean $okay If it is okay to query the slave. |
||
324 | * @throws MongoCursorException |
||
325 | * @return MongoCursor Returns this cursor |
||
326 | */ |
||
327 | public function slaveOkay($okay = true) |
||
332 | |||
333 | /** |
||
334 | * Use snapshot mode for the query |
||
335 | * @link http://www.php.net/manual/en/mongocursor.snapshot.php |
||
336 | * @throws MongoCursorException |
||
337 | * @return MongoCursor Returns this cursor |
||
338 | */ |
||
339 | public function snapshot() |
||
346 | |||
347 | /** |
||
348 | * Sorts the results by given fields |
||
349 | * @link http://www.php.net/manual/en/mongocursor.sort.php |
||
350 | * @param array $fields An array of fields by which to sort. Each element in the array has as key the field name, and as value either 1 for ascending sort, or -1 for descending sort |
||
351 | * @throws MongoCursorException |
||
352 | * @return MongoCursor Returns the same cursor that this method was called on |
||
353 | */ |
||
354 | public function sort(array $fields) |
||
361 | |||
362 | /** |
||
363 | * Sets whether this cursor will be left open after fetching the last results |
||
364 | * @link http://www.php.net/manual/en/mongocursor.tailable.php |
||
365 | * @param bool $tail If the cursor should be tailable. |
||
366 | * @return MongoCursor Returns this cursor |
||
367 | */ |
||
368 | public function tailable($tail = true) |
||
375 | |||
376 | /** |
||
377 | * @return int|null |
||
378 | */ |
||
379 | protected function convertCursorType() |
||
387 | |||
388 | protected function convertModifiers() |
||
402 | |||
403 | /** |
||
404 | * {@inheritdoc} |
||
405 | */ |
||
406 | protected function convertReadPreference() |
||
415 | |||
416 | /** |
||
417 | * @return Cursor |
||
418 | */ |
||
419 | protected function ensureCursor() |
||
427 | |||
428 | /** |
||
429 | * @return array |
||
430 | */ |
||
431 | protected function getCursorInfo() |
||
443 | } |
||
444 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.