1 | <?php |
||
16 | class MongoCursor |
||
17 | { |
||
18 | |||
19 | const DEFAULT_BATCH_SIZE = 100; |
||
20 | |||
21 | /** |
||
22 | * @var integer |
||
23 | */ |
||
24 | public static $timeout = 30000; |
||
25 | |||
26 | /** |
||
27 | * @var MongoClient |
||
28 | */ |
||
29 | private $client; |
||
30 | |||
31 | /** |
||
32 | * Full collection name |
||
33 | * @var string |
||
34 | */ |
||
35 | private $fcn; |
||
36 | |||
37 | /** |
||
38 | * @var array[] |
||
39 | */ |
||
40 | private $documents = []; |
||
|
|||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | */ |
||
45 | private $currKey = -1; |
||
46 | |||
47 | /** |
||
48 | * @var null|int |
||
49 | */ |
||
50 | private $cursorId = null; |
||
51 | |||
52 | /** |
||
53 | * @var bool |
||
54 | */ |
||
55 | private $fetching = false; |
||
56 | |||
57 | /** |
||
58 | * @var bool |
||
59 | */ |
||
60 | private $end = false; |
||
61 | |||
62 | /** |
||
63 | * @var bool |
||
64 | */ |
||
65 | private $hasMore = false; |
||
66 | |||
67 | /** |
||
68 | * @var array |
||
69 | */ |
||
70 | private $query = []; |
||
71 | |||
72 | /** |
||
73 | * @var int |
||
74 | */ |
||
75 | private $queryLimit = 0; |
||
76 | |||
77 | /** |
||
78 | * @var int |
||
79 | */ |
||
80 | private $querySkip = 0; |
||
81 | |||
82 | /** |
||
83 | * @var int |
||
84 | */ |
||
85 | private $queryTimeout = null; |
||
86 | |||
87 | /** |
||
88 | * @var int |
||
89 | */ |
||
90 | private $batchSize = self::DEFAULT_BATCH_SIZE; |
||
91 | |||
92 | /** |
||
93 | * @var int |
||
94 | */ |
||
95 | private $flags = 0; |
||
96 | |||
97 | /** |
||
98 | * @var array |
||
99 | */ |
||
100 | private $readPreference; |
||
101 | |||
102 | /** |
||
103 | * Create a new cursor |
||
104 | * |
||
105 | * @param MongoClient $client - Database connection. |
||
106 | * @param string $ns - Full name of database and collection. |
||
107 | * @param array $query - Database query. |
||
108 | * @param array $fields - Fields to return. |
||
109 | */ |
||
110 | public function __construct(MongoClient $client, $ns, array $query = [], array $fields = []) |
||
119 | |||
120 | /** |
||
121 | * Sorts the results by given fields |
||
122 | * |
||
123 | * @param array $fields - An array of fields by which to sort. Each |
||
124 | * element in the array has as key the field name, and as value either |
||
125 | * 1 for ascending sort, or -1 for descending sort. |
||
126 | * |
||
127 | * @return MongoCursor - Returns the same cursor that this method was |
||
128 | * called on. |
||
129 | */ |
||
130 | public function sort(array $fields) |
||
136 | |||
137 | /** |
||
138 | * Sets the fields for a query |
||
139 | * |
||
140 | * @param array $fields - Fields to return (or not return). |
||
141 | * |
||
142 | * @return MongoCursor - Returns this cursor. |
||
143 | */ |
||
144 | public function fields(array $fields) |
||
150 | |||
151 | /** |
||
152 | * Limits the number of results returned |
||
153 | * |
||
154 | * @param int $num - The number of results to return. |
||
155 | * |
||
156 | * @return MongoCursor - Returns this cursor. |
||
157 | */ |
||
158 | public function limit($num) |
||
164 | |||
165 | /** |
||
166 | * Skips a number of results |
||
167 | * |
||
168 | * @param int $num - The number of results to skip. |
||
169 | * |
||
170 | * @return MongoCursor - Returns this cursor. |
||
171 | */ |
||
172 | public function skip($num) |
||
178 | |||
179 | /** |
||
180 | * Gets the query, fields, limit, and skip for this cursor |
||
181 | * |
||
182 | * @return array - Returns the namespace, limit, skip, query, and |
||
183 | * fields for this cursor. |
||
184 | */ |
||
185 | public function info() |
||
203 | |||
204 | /** |
||
205 | * Counts the number of results for this query |
||
206 | * |
||
207 | * @param bool $foundOnly - |
||
208 | * |
||
209 | * @return int - The number of documents returned by this cursor's |
||
210 | * query. |
||
211 | */ |
||
212 | public function count($foundOnly = false) |
||
223 | |||
224 | private function countQuerying() |
||
239 | |||
240 | /** |
||
241 | * Execute the query. |
||
242 | * |
||
243 | * @return void - NULL. |
||
244 | */ |
||
245 | protected function doQuery() |
||
252 | |||
253 | private function fetchDocuments() |
||
263 | |||
264 | private function getQuery() |
||
273 | |||
274 | } |
||
275 |
This check marks private properties in classes that are never used. Those properties can be removed.