1: <?php
2:
3: namespace PHPixie\Database\Driver\Mongo\Query;
4:
5: abstract class Item extends \PHPixie\Database\Driver\Mongo\Query
6: implements \PHPixie\Database\Driver\Mongo\Conditions\Builder
7: {
8: public function __construct($connection, $parser, $builder)
9: {
10: parent::__construct($connection, $parser, $builder);
11:
12: $this->aliases = array_merge($this->aliases, array(
13: 'and' => '_and',
14: 'or' => '_or',
15: 'xor' => '_xor',
16: 'not' => '_not',
17: ));
18: }
19:
20: protected function addContainerOperatorCondition($logic, $negate, $field, $operator, $values, $containerName = null)
21: {
22: $this->builder->addOperatorCondition($logic, $negate, $field, $operator, $values, $containerName);
23:
24: return $this;
25: }
26:
27: protected function addContainerInOperatorCondition($field, $values, $logic, $negate, $containerName = null)
28: {
29: $this->builder->addInOperatorCondition($field, $values, $logic, $negate, $containerName);
30:
31: return $this;
32: }
33:
34: protected function buildContainerCondition($logic, $negate, $args, $containerName = null)
35: {
36: $this->builder->buildCondition($logic, $negate, $args, $containerName);
37:
38: return $this;
39: }
40:
41: protected function addContainerCondition($logic, $negate, $condition, $containerName = null)
42: {
43: $this->builder->addCondition($logic, $negate, $condition, $containerName);
44:
45: return $this;
46: }
47:
48: protected function startContainerConditionGroup($logic = 'and', $negate = false, $containerName = null)
49: {
50: $this->builder->startConditionGroup($logic, $negate, $containerName);
51:
52: return $this;
53: }
54:
55: protected function startContainerSubdocumentConditionGroup($field, $logic = 'and', $negate = false, $containerName = null)
56: {
57: $this->builder->startSubdocumentConditionGroup($field, $logic, $negate, $containerName);
58:
59: return $this;
60: }
61:
62: protected function startContainerSubarrayItemConditionGroup($field, $logic = 'and', $negate = false, $containerName = null)
63: {
64: $this->builder->startSubarrayItemConditionGroup($field, $logic, $negate, $containerName);
65:
66: return $this;
67: }
68:
69: protected function endContainerConditionGroup($containerName = null)
70: {
71: $this->builder->endConditionGroup($containerName);
72:
73: return $this;
74: }
75:
76: protected function addContainerPlaceholder($logic = 'and', $negate = false, $allowEmpty = true, $containerName = null)
77: {
78: return $this->builder->addPlaceholder($logic, $negate, $allowEmpty, $containerName);
79: }
80:
81: protected function addContainerSubdocumentPlaceholder($field, $logic = 'and', $negate = false, $allowEmpty = true, $containerName = null)
82: {
83: return $this->builder->addSubdocumentPlaceholder($field, $logic, $negate, $allowEmpty, $containerName);
84: }
85:
86: protected function addContainerSubarrayItemPlaceholder($field, $logic = 'and', $negate = false, $allowEmpty = true, $containerName = null)
87: {
88: return $this->builder->addSubarrayItemPlaceholder($field, $logic, $negate, $allowEmpty, $containerName);
89: }
90:
91: public function addCondition($logic, $negate, $condition)
92: {
93: $this->builder->addCondition($logic, $negate, $condition);
94: return $this;
95: }
96:
97: public function buildCondition($logic, $negate, $params)
98: {
99: $this->builder->buildCondition($logic, $negate, $params);
100: return $this;
101: }
102:
103: public function buildWhereCondition($logic, $negate, $condition)
104: {
105: return $this->buildContainerCondition($logic, $negate, $condition, 'where');
106: }
107:
108: public function addWhereCondition($logic, $negate, $container)
109: {
110: return $this->addContainerCondition($logic, $negate, $container, 'where');
111: }
112:
113: public function getWhereContainer()
114: {
115: return $this->builder->conditionContainer('where');
116: }
117:
118: public function getWhereConditions()
119: {
120: return $this->builder->getConditions('where');
121: }
122:
123: public function addOperatorCondition($logic, $negate, $field, $operator, $values)
124: {
125: return $this->addContainerOperatorCondition($logic, $negate, $field, $operator, $values);
126: }
127:
128: public function addWhereOperatorCondition($logic, $negate, $field, $operator, $values)
129: {
130: return $this->addContainerOperatorCondition($logic, $negate, $field, $operator, $values, 'where');
131: }
132:
133: public function addInOperatorCondition($field, $values, $logic = 'and', $negate = false)
134: {
135: return $this->addContainerInOperatorCondition($field, $values, $logic, $negate);
136: }
137:
138: public function addWhereInOperatorCondition($field, $values, $logic = 'and', $negate = false)
139: {
140: return $this->addContainerInOperatorCondition($field, $values, $logic, $negate, 'where');
141: }
142:
143: public function startConditionGroup($logic = 'and', $negate = false)
144: {
145: return $this->startContainerConditionGroup($logic, $negate);
146: }
147:
148: public function startWhereConditionGroup($logic = 'and', $negate = false)
149: {
150: return $this->startContainerConditionGroup($logic, $negate, 'where');
151: }
152:
153: public function startSubdocumentConditionGroup($field, $logic = 'and', $negate = false)
154: {
155: return $this->startContainerSubdocumentConditionGroup($field, $logic, $negate);
156: }
157:
158: public function startWhereSubdocumentConditionGroup($field, $logic = 'and', $negate = false)
159: {
160: return $this->startContainerSubdocumentConditionGroup($field, $logic, $negate, 'where');
161: }
162:
163: public function startSubarrayItemConditionGroup($field, $logic = 'and', $negate = false)
164: {
165: return $this->startContainerSubarrayItemConditionGroup($field, $logic, $negate);
166: }
167:
168: public function startWhereSubarrayItemConditionGroup($field, $logic = 'and', $negate = false)
169: {
170: return $this->startContainerSubarrayItemConditionGroup($field, $logic, $negate, 'where');
171: }
172:
173: public function addPlaceholder($logic = 'and', $negate = false, $allowEmpty = true)
174: {
175: return $this->addContainerPlaceholder($logic, $negate, $allowEmpty);
176: }
177:
178: public function addWherePlaceholder($logic = 'and', $negate = false, $allowEmpty = true)
179: {
180: return $this->addContainerPlaceholder($logic, $negate, $allowEmpty, 'where');
181: }
182:
183: public function addSubdocumentPlaceholder($field, $logic = 'and', $negate = false, $allowEmpty = true)
184: {
185: return $this->addContainerSubdocumentPlaceholder($field, $logic, $negate, $allowEmpty);
186: }
187:
188: public function addWhereSubdocumentPlaceholder($field, $logic = 'and', $negate = false, $allowEmpty = true)
189: {
190: return $this->addContainerSubdocumentPlaceholder($field, $logic, $negate, $allowEmpty, 'where');
191: }
192:
193: public function addSubarrayItemPlaceholder($field, $logic = 'and', $negate = false, $allowEmpty = true)
194: {
195: return $this->addContainerSubarrayItemPlaceholder($field, $logic, $negate, $allowEmpty);
196: }
197:
198: public function addWhereSubarrayItemPlaceholder($field, $logic = 'and', $negate = false, $allowEmpty = true)
199: {
200: return $this->addContainerSubarrayItemPlaceholder($field, $logic, $negate, $allowEmpty, 'where');
201: }
202:
203: public function where()
204: {
205: return $this->buildContainerCondition('and', false, func_get_args(), 'where');
206: }
207:
208: public function andWhere()
209: {
210: return $this->buildContainerCondition('and', false, func_get_args(), 'where');
211: }
212:
213: public function orWhere()
214: {
215: return $this->buildContainerCondition('or', false, func_get_args(), 'where');
216: }
217:
218: public function xorWhere()
219: {
220: return $this->buildContainerCondition('xor', false, func_get_args(), 'where');
221: }
222:
223: public function whereNot()
224: {
225: return $this->buildContainerCondition('and', true, func_get_args(), 'where');
226: }
227:
228: public function andWhereNot()
229: {
230: return $this->buildContainerCondition('and', true, func_get_args(), 'where');
231: }
232:
233: public function orWhereNot()
234: {
235: return $this->buildContainerCondition('or', true, func_get_args(), 'where');
236: }
237:
238: public function xorWhereNot()
239: {
240: return $this->buildContainerCondition('xor', true, func_get_args(), 'where');
241: }
242:
243: public function startWhereGroup()
244: {
245: return $this->startContainerConditionGroup('and', false, 'where');
246: }
247:
248: public function startAndWhereGroup()
249: {
250: return $this->startContainerConditionGroup('and', false, 'where');
251: }
252:
253: public function startOrWhereGroup()
254: {
255: return $this->startContainerConditionGroup('or', false, 'where');
256: }
257:
258: public function startXorWhereGroup()
259: {
260: return $this->startContainerConditionGroup('xor', false, 'where');
261: }
262:
263: public function startWhereNotGroup()
264: {
265: return $this->startContainerConditionGroup('and', true, 'where');
266: }
267:
268: public function startAndWhereNotGroup()
269: {
270: return $this->startContainerConditionGroup('and', true, 'where');
271: }
272:
273: public function startOrWhereNotGroup()
274: {
275: return $this->startContainerConditionGroup('or', true, 'where');
276: }
277:
278: public function startXorWhereNotGroup()
279: {
280: return $this->startContainerConditionGroup('xor', true, 'where');
281: }
282:
283: public function endWhereGroup()
284: {
285: return $this->endContainerConditionGroup('where');
286: }
287:
288: public function _and()
289: {
290: return $this->buildContainerCondition('and', false, func_get_args());
291: }
292:
293: public function _or()
294: {
295: return $this->buildContainerCondition('or', false, func_get_args());
296: }
297:
298: public function _xor()
299: {
300: return $this->buildContainerCondition('xor', false, func_get_args());
301: }
302:
303: public function _not()
304: {
305: return $this->buildContainerCondition('and', true, func_get_args());
306: }
307:
308: public function andNot()
309: {
310: return $this->buildContainerCondition('and', true, func_get_args());
311: }
312:
313: public function orNot()
314: {
315: return $this->buildContainerCondition('or', true, func_get_args());
316: }
317:
318: public function xorNot()
319: {
320: return $this->buildContainerCondition('xor', true, func_get_args());
321: }
322:
323: public function startGroup()
324: {
325: return $this->startConditionGroup('and', false);
326: }
327:
328: public function startAndGroup()
329: {
330: return $this->startConditionGroup('and', false);
331: }
332:
333: public function startOrGroup()
334: {
335: return $this->startConditionGroup('or', false);
336: }
337:
338: public function startXorGroup()
339: {
340: return $this->startConditionGroup('xor', false);
341: }
342:
343: public function startNotGroup()
344: {
345: return $this->startConditionGroup('and', true);
346: }
347:
348: public function startAndNotGroup()
349: {
350: return $this->startConditionGroup('and', true);
351: }
352:
353: public function startOrNotGroup()
354: {
355: return $this->startConditionGroup('or', true);
356: }
357:
358: public function startXorNotGroup()
359: {
360: return $this->startConditionGroup('xor', true);
361: }
362:
363:
364:
365: public function startSubdocumentGroup($field)
366: {
367: return $this->startSubdocumentConditionGroup($field, 'and', false);
368: }
369:
370: public function startAndSubdocumentGroup($field)
371: {
372: return $this->startSubdocumentConditionGroup($field, 'and', false);
373: }
374:
375: public function startOrSubdocumentGroup($field)
376: {
377: return $this->startSubdocumentConditionGroup($field, 'or', false);
378: }
379:
380: public function startXorSubdocumentGroup($field)
381: {
382: return $this->startSubdocumentConditionGroup($field, 'xor', false);
383: }
384:
385: public function startNotSubdocumentGroup($field)
386: {
387: return $this->startSubdocumentConditionGroup($field, 'and', true);
388: }
389:
390: public function startAndNotSubdocumentGroup($field)
391: {
392: return $this->startSubdocumentConditionGroup($field, 'and', true);
393: }
394:
395: public function startOrNotSubdocumentGroup($field)
396: {
397: return $this->startSubdocumentConditionGroup($field, 'or', true);
398: }
399:
400: public function startXorNotSubdocumentGroup($field)
401: {
402: return $this->startSubdocumentConditionGroup($field, 'xor', true);
403: }
404:
405: public function startSubarrayItemGroup($field)
406: {
407: return $this->startSubarrayItemConditionGroup($field, 'and', false);
408: }
409:
410: public function startAndSubarrayItemGroup($field)
411: {
412: return $this->startSubarrayItemConditionGroup($field, 'and', false);
413: }
414:
415: public function startOrSubarrayItemGroup($field)
416: {
417: return $this->startSubarrayItemConditionGroup($field, 'or', false);
418: }
419:
420: public function startXorSubarrayItemGroup($field)
421: {
422: return $this->startSubarrayItemConditionGroup($field, 'xor', false);
423: }
424:
425: public function startNotSubarrayItemGroup($field)
426: {
427: return $this->startSubarrayItemConditionGroup($field, 'and', true);
428: }
429:
430: public function startAndNotSubarrayItemGroup($field)
431: {
432: return $this->startSubarrayItemConditionGroup($field, 'and', true);
433: }
434:
435: public function startOrNotSubarrayItemGroup($field)
436: {
437: return $this->startSubarrayItemConditionGroup($field, 'or', true);
438: }
439:
440: public function startXorNotSubarrayItemGroup($field)
441: {
442: return $this->startSubarrayItemConditionGroup($field, 'xor', true);
443: }
444:
445:
446:
447: public function startWhereSubdocumentGroup($field)
448: {
449: return $this->startWhereSubdocumentConditionGroup($field, 'and', false);
450: }
451:
452: public function startAndWhereSubdocumentGroup($field)
453: {
454: return $this->startWhereSubdocumentConditionGroup($field, 'and', false);
455: }
456:
457: public function startOrWhereSubdocumentGroup($field)
458: {
459: return $this->startWhereSubdocumentConditionGroup($field, 'or', false);
460: }
461:
462: public function startXorWhereSubdocumentGroup($field)
463: {
464: return $this->startWhereSubdocumentConditionGroup($field, 'xor', false);
465: }
466:
467: public function startWhereNotSubdocumentGroup($field)
468: {
469: return $this->startWhereSubdocumentConditionGroup($field, 'and', true);
470: }
471:
472: public function startAndWhereNotSubdocumentGroup($field)
473: {
474: return $this->startWhereSubdocumentConditionGroup($field, 'and', true);
475: }
476:
477: public function startOrWhereNotSubdocumentGroup($field)
478: {
479: return $this->startWhereSubdocumentConditionGroup($field, 'or', true);
480: }
481:
482: public function startXorWhereNotSubdocumentGroup($field)
483: {
484: return $this->startWhereSubdocumentConditionGroup($field, 'xor', true);
485: }
486:
487: public function startWhereSubarrayItemGroup($field)
488: {
489: return $this->startWhereSubarrayItemConditionGroup($field, 'and', false);
490: }
491:
492: public function startAndWhereSubarrayItemGroup($field)
493: {
494: return $this->startWhereSubarrayItemConditionGroup($field, 'and', false);
495: }
496:
497: public function startOrWhereSubarrayItemGroup($field)
498: {
499: return $this->startWhereSubarrayItemConditionGroup($field, 'or', false);
500: }
501:
502: public function startXorWhereSubarrayItemGroup($field)
503: {
504: return $this->startWhereSubarrayItemConditionGroup($field, 'xor', false);
505: }
506:
507: public function startWhereNotSubarrayItemGroup($field)
508: {
509: return $this->startWhereSubarrayItemConditionGroup($field, 'and', true);
510: }
511:
512: public function startAndWhereNotSubarrayItemGroup($field)
513: {
514: return $this->startWhereSubarrayItemConditionGroup($field, 'and', true);
515: }
516:
517: public function startOrWhereNotSubarrayItemGroup($field)
518: {
519: return $this->startWhereSubarrayItemConditionGroup($field, 'or', true);
520: }
521:
522: public function startXorWhereNotSubarrayItemGroup($field)
523: {
524: return $this->startWhereSubarrayItemConditionGroup($field, 'xor', true);
525: }
526:
527: public function endGroup()
528: {
529: return $this->endContainerConditionGroup();
530: }
531: }
532: