Completed
Push — master ( 274106...ede723 )
by Morris
25:06 queued 10s
created
lib/public/DB/QueryBuilder/IQueryBuilder.php 1 patch
Indentation   +867 added lines, -867 removed lines patch added patch discarded remove patch
@@ -33,871 +33,871 @@
 block discarded – undo
33 33
  */
34 34
 interface IQueryBuilder {
35 35
 
36
-	/**
37
-	 * @since 9.0.0
38
-	 */
39
-	const PARAM_NULL = \PDO::PARAM_NULL;
40
-	/**
41
-	 * @since 9.0.0
42
-	 */
43
-	const PARAM_BOOL = \PDO::PARAM_BOOL;
44
-	/**
45
-	 * @since 9.0.0
46
-	 */
47
-	const PARAM_INT = \PDO::PARAM_INT;
48
-	/**
49
-	 * @since 9.0.0
50
-	 */
51
-	const PARAM_STR = \PDO::PARAM_STR;
52
-	/**
53
-	 * @since 9.0.0
54
-	 */
55
-	const PARAM_LOB = \PDO::PARAM_LOB;
56
-	/**
57
-	 * @since 9.0.0
58
-	 */
59
-	const PARAM_DATE = 'datetime';
60
-
61
-	/**
62
-	 * @since 9.0.0
63
-	 */
64
-	const PARAM_INT_ARRAY = Connection::PARAM_INT_ARRAY;
65
-	/**
66
-	 * @since 9.0.0
67
-	 */
68
-	const PARAM_STR_ARRAY = Connection::PARAM_STR_ARRAY;
69
-
70
-
71
-	/**
72
-	 * Enable/disable automatic prefixing of table names with the oc_ prefix
73
-	 *
74
-	 * @param bool $enabled If set to true table names will be prefixed with the
75
-	 * owncloud database prefix automatically.
76
-	 * @since 8.2.0
77
-	 */
78
-	public function automaticTablePrefix($enabled);
79
-
80
-	/**
81
-	 * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
82
-	 * This producer method is intended for convenient inline usage. Example:
83
-	 *
84
-	 * <code>
85
-	 *     $qb = $conn->getQueryBuilder()
86
-	 *         ->select('u')
87
-	 *         ->from('users', 'u')
88
-	 *         ->where($qb->expr()->eq('u.id', 1));
89
-	 * </code>
90
-	 *
91
-	 * For more complex expression construction, consider storing the expression
92
-	 * builder object in a local variable.
93
-	 *
94
-	 * @return \OCP\DB\QueryBuilder\IExpressionBuilder
95
-	 * @since 8.2.0
96
-	 */
97
-	public function expr();
98
-
99
-	/**
100
-	 * Gets an FunctionBuilder used for object-oriented construction of query functions.
101
-	 * This producer method is intended for convenient inline usage. Example:
102
-	 *
103
-	 * <code>
104
-	 *     $qb = $conn->getQueryBuilder()
105
-	 *         ->select('u')
106
-	 *         ->from('users', 'u')
107
-	 *         ->where($qb->fun()->md5('u.id'));
108
-	 * </code>
109
-	 *
110
-	 * For more complex function construction, consider storing the function
111
-	 * builder object in a local variable.
112
-	 *
113
-	 * @return \OCP\DB\QueryBuilder\IFunctionBuilder
114
-	 * @since 12.0.0
115
-	 */
116
-	public function func();
117
-
118
-	/**
119
-	 * Gets the type of the currently built query.
120
-	 *
121
-	 * @return integer
122
-	 * @since 8.2.0
123
-	 */
124
-	public function getType();
125
-
126
-	/**
127
-	 * Gets the associated DBAL Connection for this query builder.
128
-	 *
129
-	 * @return \OCP\IDBConnection
130
-	 * @since 8.2.0
131
-	 */
132
-	public function getConnection();
133
-
134
-	/**
135
-	 * Gets the state of this query builder instance.
136
-	 *
137
-	 * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.
138
-	 * @since 8.2.0
139
-	 */
140
-	public function getState();
141
-
142
-	/**
143
-	 * Executes this query using the bound parameters and their types.
144
-	 *
145
-	 * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
146
-	 * for insert, update and delete statements.
147
-	 *
148
-	 * @return \Doctrine\DBAL\Driver\Statement|int
149
-	 * @since 8.2.0
150
-	 */
151
-	public function execute();
152
-
153
-	/**
154
-	 * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
155
-	 *
156
-	 * <code>
157
-	 *     $qb = $conn->getQueryBuilder()
158
-	 *         ->select('u')
159
-	 *         ->from('User', 'u')
160
-	 *     echo $qb->getSQL(); // SELECT u FROM User u
161
-	 * </code>
162
-	 *
163
-	 * @return string The SQL query string.
164
-	 * @since 8.2.0
165
-	 */
166
-	public function getSQL();
167
-
168
-	/**
169
-	 * Sets a query parameter for the query being constructed.
170
-	 *
171
-	 * <code>
172
-	 *     $qb = $conn->getQueryBuilder()
173
-	 *         ->select('u')
174
-	 *         ->from('users', 'u')
175
-	 *         ->where('u.id = :user_id')
176
-	 *         ->setParameter(':user_id', 1);
177
-	 * </code>
178
-	 *
179
-	 * @param string|integer $key The parameter position or name.
180
-	 * @param mixed $value The parameter value.
181
-	 * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
182
-	 *
183
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
184
-	 * @since 8.2.0
185
-	 */
186
-	public function setParameter($key, $value, $type = null);
187
-
188
-	/**
189
-	 * Sets a collection of query parameters for the query being constructed.
190
-	 *
191
-	 * <code>
192
-	 *     $qb = $conn->getQueryBuilder()
193
-	 *         ->select('u')
194
-	 *         ->from('users', 'u')
195
-	 *         ->where('u.id = :user_id1 OR u.id = :user_id2')
196
-	 *         ->setParameters(array(
197
-	 *             ':user_id1' => 1,
198
-	 *             ':user_id2' => 2
199
-	 *         ));
200
-	 * </code>
201
-	 *
202
-	 * @param array $params The query parameters to set.
203
-	 * @param array $types The query parameters types to set.
204
-	 *
205
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
206
-	 * @since 8.2.0
207
-	 */
208
-	public function setParameters(array $params, array $types = array());
209
-
210
-	/**
211
-	 * Gets all defined query parameters for the query being constructed indexed by parameter index or name.
212
-	 *
213
-	 * @return array The currently defined query parameters indexed by parameter index or name.
214
-	 * @since 8.2.0
215
-	 */
216
-	public function getParameters();
217
-
218
-	/**
219
-	 * Gets a (previously set) query parameter of the query being constructed.
220
-	 *
221
-	 * @param mixed $key The key (index or name) of the bound parameter.
222
-	 *
223
-	 * @return mixed The value of the bound parameter.
224
-	 * @since 8.2.0
225
-	 */
226
-	public function getParameter($key);
227
-
228
-	/**
229
-	 * Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
230
-	 *
231
-	 * @return array The currently defined query parameter types indexed by parameter index or name.
232
-	 * @since 8.2.0
233
-	 */
234
-	public function getParameterTypes();
235
-
236
-	/**
237
-	 * Gets a (previously set) query parameter type of the query being constructed.
238
-	 *
239
-	 * @param mixed $key The key (index or name) of the bound parameter type.
240
-	 *
241
-	 * @return mixed The value of the bound parameter type.
242
-	 * @since 8.2.0
243
-	 */
244
-	public function getParameterType($key);
245
-
246
-	/**
247
-	 * Sets the position of the first result to retrieve (the "offset").
248
-	 *
249
-	 * @param integer $firstResult The first result to return.
250
-	 *
251
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
252
-	 * @since 8.2.0
253
-	 */
254
-	public function setFirstResult($firstResult);
255
-
256
-	/**
257
-	 * Gets the position of the first result the query object was set to retrieve (the "offset").
258
-	 * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
259
-	 *
260
-	 * @return integer The position of the first result.
261
-	 * @since 8.2.0
262
-	 */
263
-	public function getFirstResult();
264
-
265
-	/**
266
-	 * Sets the maximum number of results to retrieve (the "limit").
267
-	 *
268
-	 * @param integer $maxResults The maximum number of results to retrieve.
269
-	 *
270
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
271
-	 * @since 8.2.0
272
-	 */
273
-	public function setMaxResults($maxResults);
274
-
275
-	/**
276
-	 * Gets the maximum number of results the query object was set to retrieve (the "limit").
277
-	 * Returns NULL if {@link setMaxResults} was not applied to this query builder.
278
-	 *
279
-	 * @return integer The maximum number of results.
280
-	 * @since 8.2.0
281
-	 */
282
-	public function getMaxResults();
283
-
284
-	/**
285
-	 * Specifies an item that is to be returned in the query result.
286
-	 * Replaces any previously specified selections, if any.
287
-	 *
288
-	 * <code>
289
-	 *     $qb = $conn->getQueryBuilder()
290
-	 *         ->select('u.id', 'p.id')
291
-	 *         ->from('users', 'u')
292
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
293
-	 * </code>
294
-	 *
295
-	 * @param mixed ...$selects The selection expressions.
296
-	 *
297
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
298
-	 * @since 8.2.0
299
-	 */
300
-	public function select(...$selects);
301
-
302
-	/**
303
-	 * Specifies an item that is to be returned with a different name in the query result.
304
-	 *
305
-	 * <code>
306
-	 *     $qb = $conn->getQueryBuilder()
307
-	 *         ->selectAlias('u.id', 'user_id')
308
-	 *         ->from('users', 'u')
309
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
310
-	 * </code>
311
-	 *
312
-	 * @param mixed $select The selection expressions.
313
-	 * @param string $alias The column alias used in the constructed query.
314
-	 *
315
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
316
-	 * @since 8.2.1
317
-	 */
318
-	public function selectAlias($select, $alias);
319
-
320
-	/**
321
-	 * Specifies an item that is to be returned uniquely in the query result.
322
-	 *
323
-	 * <code>
324
-	 *     $qb = $conn->getQueryBuilder()
325
-	 *         ->selectDistinct('type')
326
-	 *         ->from('users');
327
-	 * </code>
328
-	 *
329
-	 * @param mixed $select The selection expressions.
330
-	 *
331
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
332
-	 * @since 9.0.0
333
-	 */
334
-	public function selectDistinct($select);
335
-
336
-	/**
337
-	 * Adds an item that is to be returned in the query result.
338
-	 *
339
-	 * <code>
340
-	 *     $qb = $conn->getQueryBuilder()
341
-	 *         ->select('u.id')
342
-	 *         ->addSelect('p.id')
343
-	 *         ->from('users', 'u')
344
-	 *         ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
345
-	 * </code>
346
-	 *
347
-	 * @param mixed ...$select The selection expression.
348
-	 *
349
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
350
-	 * @since 8.2.0
351
-	 */
352
-	public function addSelect(...$select);
353
-
354
-	/**
355
-	 * Turns the query being built into a bulk delete query that ranges over
356
-	 * a certain table.
357
-	 *
358
-	 * <code>
359
-	 *     $qb = $conn->getQueryBuilder()
360
-	 *         ->delete('users', 'u')
361
-	 *         ->where('u.id = :user_id');
362
-	 *         ->setParameter(':user_id', 1);
363
-	 * </code>
364
-	 *
365
-	 * @param string $delete The table whose rows are subject to the deletion.
366
-	 * @param string $alias The table alias used in the constructed query.
367
-	 *
368
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
369
-	 * @since 8.2.0
370
-	 */
371
-	public function delete($delete = null, $alias = null);
372
-
373
-	/**
374
-	 * Turns the query being built into a bulk update query that ranges over
375
-	 * a certain table
376
-	 *
377
-	 * <code>
378
-	 *     $qb = $conn->getQueryBuilder()
379
-	 *         ->update('users', 'u')
380
-	 *         ->set('u.password', md5('password'))
381
-	 *         ->where('u.id = ?');
382
-	 * </code>
383
-	 *
384
-	 * @param string $update The table whose rows are subject to the update.
385
-	 * @param string $alias The table alias used in the constructed query.
386
-	 *
387
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
388
-	 * @since 8.2.0
389
-	 */
390
-	public function update($update = null, $alias = null);
391
-
392
-	/**
393
-	 * Turns the query being built into an insert query that inserts into
394
-	 * a certain table
395
-	 *
396
-	 * <code>
397
-	 *     $qb = $conn->getQueryBuilder()
398
-	 *         ->insert('users')
399
-	 *         ->values(
400
-	 *             array(
401
-	 *                 'name' => '?',
402
-	 *                 'password' => '?'
403
-	 *             )
404
-	 *         );
405
-	 * </code>
406
-	 *
407
-	 * @param string $insert The table into which the rows should be inserted.
408
-	 *
409
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
410
-	 * @since 8.2.0
411
-	 */
412
-	public function insert($insert = null);
413
-
414
-	/**
415
-	 * Creates and adds a query root corresponding to the table identified by the
416
-	 * given alias, forming a cartesian product with any existing query roots.
417
-	 *
418
-	 * <code>
419
-	 *     $qb = $conn->getQueryBuilder()
420
-	 *         ->select('u.id')
421
-	 *         ->from('users', 'u')
422
-	 * </code>
423
-	 *
424
-	 * @param string $from The table.
425
-	 * @param string|null $alias The alias of the table.
426
-	 *
427
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
428
-	 * @since 8.2.0
429
-	 */
430
-	public function from($from, $alias = null);
431
-
432
-	/**
433
-	 * Creates and adds a join to the query.
434
-	 *
435
-	 * <code>
436
-	 *     $qb = $conn->getQueryBuilder()
437
-	 *         ->select('u.name')
438
-	 *         ->from('users', 'u')
439
-	 *         ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
440
-	 * </code>
441
-	 *
442
-	 * @param string $fromAlias The alias that points to a from clause.
443
-	 * @param string $join The table name to join.
444
-	 * @param string $alias The alias of the join table.
445
-	 * @param string $condition The condition for the join.
446
-	 *
447
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
448
-	 * @since 8.2.0
449
-	 */
450
-	public function join($fromAlias, $join, $alias, $condition = null);
451
-
452
-	/**
453
-	 * Creates and adds a join to the query.
454
-	 *
455
-	 * <code>
456
-	 *     $qb = $conn->getQueryBuilder()
457
-	 *         ->select('u.name')
458
-	 *         ->from('users', 'u')
459
-	 *         ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
460
-	 * </code>
461
-	 *
462
-	 * @param string $fromAlias The alias that points to a from clause.
463
-	 * @param string $join The table name to join.
464
-	 * @param string $alias The alias of the join table.
465
-	 * @param string $condition The condition for the join.
466
-	 *
467
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
468
-	 * @since 8.2.0
469
-	 */
470
-	public function innerJoin($fromAlias, $join, $alias, $condition = null);
471
-
472
-	/**
473
-	 * Creates and adds a left join to the query.
474
-	 *
475
-	 * <code>
476
-	 *     $qb = $conn->getQueryBuilder()
477
-	 *         ->select('u.name')
478
-	 *         ->from('users', 'u')
479
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
480
-	 * </code>
481
-	 *
482
-	 * @param string $fromAlias The alias that points to a from clause.
483
-	 * @param string $join The table name to join.
484
-	 * @param string $alias The alias of the join table.
485
-	 * @param string $condition The condition for the join.
486
-	 *
487
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
488
-	 * @since 8.2.0
489
-	 */
490
-	public function leftJoin($fromAlias, $join, $alias, $condition = null);
491
-
492
-	/**
493
-	 * Creates and adds a right join to the query.
494
-	 *
495
-	 * <code>
496
-	 *     $qb = $conn->getQueryBuilder()
497
-	 *         ->select('u.name')
498
-	 *         ->from('users', 'u')
499
-	 *         ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
500
-	 * </code>
501
-	 *
502
-	 * @param string $fromAlias The alias that points to a from clause.
503
-	 * @param string $join The table name to join.
504
-	 * @param string $alias The alias of the join table.
505
-	 * @param string $condition The condition for the join.
506
-	 *
507
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
508
-	 * @since 8.2.0
509
-	 */
510
-	public function rightJoin($fromAlias, $join, $alias, $condition = null);
511
-
512
-	/**
513
-	 * Sets a new value for a column in a bulk update query.
514
-	 *
515
-	 * <code>
516
-	 *     $qb = $conn->getQueryBuilder()
517
-	 *         ->update('users', 'u')
518
-	 *         ->set('u.password', md5('password'))
519
-	 *         ->where('u.id = ?');
520
-	 * </code>
521
-	 *
522
-	 * @param string $key The column to set.
523
-	 * @param string $value The value, expression, placeholder, etc.
524
-	 *
525
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
526
-	 * @since 8.2.0
527
-	 */
528
-	public function set($key, $value);
529
-
530
-	/**
531
-	 * Specifies one or more restrictions to the query result.
532
-	 * Replaces any previously specified restrictions, if any.
533
-	 *
534
-	 * <code>
535
-	 *     $qb = $conn->getQueryBuilder()
536
-	 *         ->select('u.name')
537
-	 *         ->from('users', 'u')
538
-	 *         ->where('u.id = ?');
539
-	 *
540
-	 *     // You can optionally programatically build and/or expressions
541
-	 *     $qb = $conn->getQueryBuilder();
542
-	 *
543
-	 *     $or = $qb->expr()->orx();
544
-	 *     $or->add($qb->expr()->eq('u.id', 1));
545
-	 *     $or->add($qb->expr()->eq('u.id', 2));
546
-	 *
547
-	 *     $qb->update('users', 'u')
548
-	 *         ->set('u.password', md5('password'))
549
-	 *         ->where($or);
550
-	 * </code>
551
-	 *
552
-	 * @param mixed $predicates The restriction predicates.
553
-	 *
554
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
555
-	 * @since 8.2.0
556
-	 */
557
-	public function where(...$predicates);
558
-
559
-	/**
560
-	 * Adds one or more restrictions to the query results, forming a logical
561
-	 * conjunction with any previously specified restrictions.
562
-	 *
563
-	 * <code>
564
-	 *     $qb = $conn->getQueryBuilder()
565
-	 *         ->select('u')
566
-	 *         ->from('users', 'u')
567
-	 *         ->where('u.username LIKE ?')
568
-	 *         ->andWhere('u.is_active = 1');
569
-	 * </code>
570
-	 *
571
-	 * @param mixed ...$where The query restrictions.
572
-	 *
573
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
574
-	 *
575
-	 * @see where()
576
-	 * @since 8.2.0
577
-	 */
578
-	public function andWhere(...$where);
579
-
580
-	/**
581
-	 * Adds one or more restrictions to the query results, forming a logical
582
-	 * disjunction with any previously specified restrictions.
583
-	 *
584
-	 * <code>
585
-	 *     $qb = $conn->getQueryBuilder()
586
-	 *         ->select('u.name')
587
-	 *         ->from('users', 'u')
588
-	 *         ->where('u.id = 1')
589
-	 *         ->orWhere('u.id = 2');
590
-	 * </code>
591
-	 *
592
-	 * @param mixed ...$where The WHERE statement.
593
-	 *
594
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
595
-	 *
596
-	 * @see where()
597
-	 * @since 8.2.0
598
-	 */
599
-	public function orWhere(...$where);
600
-
601
-	/**
602
-	 * Specifies a grouping over the results of the query.
603
-	 * Replaces any previously specified groupings, if any.
604
-	 *
605
-	 * <code>
606
-	 *     $qb = $conn->getQueryBuilder()
607
-	 *         ->select('u.name')
608
-	 *         ->from('users', 'u')
609
-	 *         ->groupBy('u.id');
610
-	 * </code>
611
-	 *
612
-	 * @param mixed ...$groupBys The grouping expression.
613
-	 *
614
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
615
-	 * @since 8.2.0
616
-	 */
617
-	public function groupBy(...$groupBys);
618
-
619
-	/**
620
-	 * Adds a grouping expression to the query.
621
-	 *
622
-	 * <code>
623
-	 *     $qb = $conn->getQueryBuilder()
624
-	 *         ->select('u.name')
625
-	 *         ->from('users', 'u')
626
-	 *         ->groupBy('u.lastLogin');
627
-	 *         ->addGroupBy('u.createdAt')
628
-	 * </code>
629
-	 *
630
-	 * @param mixed ...$groupBy The grouping expression.
631
-	 *
632
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
633
-	 * @since 8.2.0
634
-	 */
635
-	public function addGroupBy(...$groupBy);
636
-
637
-	/**
638
-	 * Sets a value for a column in an insert query.
639
-	 *
640
-	 * <code>
641
-	 *     $qb = $conn->getQueryBuilder()
642
-	 *         ->insert('users')
643
-	 *         ->values(
644
-	 *             array(
645
-	 *                 'name' => '?'
646
-	 *             )
647
-	 *         )
648
-	 *         ->setValue('password', '?');
649
-	 * </code>
650
-	 *
651
-	 * @param string $column The column into which the value should be inserted.
652
-	 * @param string $value The value that should be inserted into the column.
653
-	 *
654
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
655
-	 * @since 8.2.0
656
-	 */
657
-	public function setValue($column, $value);
658
-
659
-	/**
660
-	 * Specifies values for an insert query indexed by column names.
661
-	 * Replaces any previous values, if any.
662
-	 *
663
-	 * <code>
664
-	 *     $qb = $conn->getQueryBuilder()
665
-	 *         ->insert('users')
666
-	 *         ->values(
667
-	 *             array(
668
-	 *                 'name' => '?',
669
-	 *                 'password' => '?'
670
-	 *             )
671
-	 *         );
672
-	 * </code>
673
-	 *
674
-	 * @param array $values The values to specify for the insert query indexed by column names.
675
-	 *
676
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
677
-	 * @since 8.2.0
678
-	 */
679
-	public function values(array $values);
680
-
681
-	/**
682
-	 * Specifies a restriction over the groups of the query.
683
-	 * Replaces any previous having restrictions, if any.
684
-	 *
685
-	 * @param mixed ...$having The restriction over the groups.
686
-	 *
687
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
688
-	 * @since 8.2.0
689
-	 */
690
-	public function having(...$having);
691
-
692
-	/**
693
-	 * Adds a restriction over the groups of the query, forming a logical
694
-	 * conjunction with any existing having restrictions.
695
-	 *
696
-	 * @param mixed ...$having The restriction to append.
697
-	 *
698
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
699
-	 * @since 8.2.0
700
-	 */
701
-	public function andHaving(...$having);
702
-
703
-	/**
704
-	 * Adds a restriction over the groups of the query, forming a logical
705
-	 * disjunction with any existing having restrictions.
706
-	 *
707
-	 * @param mixed ...$having The restriction to add.
708
-	 *
709
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
710
-	 * @since 8.2.0
711
-	 */
712
-	public function orHaving(...$having);
713
-
714
-	/**
715
-	 * Specifies an ordering for the query results.
716
-	 * Replaces any previously specified orderings, if any.
717
-	 *
718
-	 * @param string $sort The ordering expression.
719
-	 * @param string $order The ordering direction.
720
-	 *
721
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
722
-	 * @since 8.2.0
723
-	 */
724
-	public function orderBy($sort, $order = null);
725
-
726
-	/**
727
-	 * Adds an ordering to the query results.
728
-	 *
729
-	 * @param string $sort The ordering expression.
730
-	 * @param string $order The ordering direction.
731
-	 *
732
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
733
-	 * @since 8.2.0
734
-	 */
735
-	public function addOrderBy($sort, $order = null);
736
-
737
-	/**
738
-	 * Gets a query part by its name.
739
-	 *
740
-	 * @param string $queryPartName
741
-	 *
742
-	 * @return mixed
743
-	 * @since 8.2.0
744
-	 */
745
-	public function getQueryPart($queryPartName);
746
-
747
-	/**
748
-	 * Gets all query parts.
749
-	 *
750
-	 * @return array
751
-	 * @since 8.2.0
752
-	 */
753
-	public function getQueryParts();
754
-
755
-	/**
756
-	 * Resets SQL parts.
757
-	 *
758
-	 * @param array|null $queryPartNames
759
-	 *
760
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
761
-	 * @since 8.2.0
762
-	 */
763
-	public function resetQueryParts($queryPartNames = null);
764
-
765
-	/**
766
-	 * Resets a single SQL part.
767
-	 *
768
-	 * @param string $queryPartName
769
-	 *
770
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
771
-	 * @since 8.2.0
772
-	 */
773
-	public function resetQueryPart($queryPartName);
774
-
775
-	/**
776
-	 * Creates a new named parameter and bind the value $value to it.
777
-	 *
778
-	 * This method provides a shortcut for PDOStatement::bindValue
779
-	 * when using prepared statements.
780
-	 *
781
-	 * The parameter $value specifies the value that you want to bind. If
782
-	 * $placeholder is not provided bindValue() will automatically create a
783
-	 * placeholder for you. An automatic placeholder will be of the name
784
-	 * ':dcValue1', ':dcValue2' etc.
785
-	 *
786
-	 * For more information see {@link http://php.net/pdostatement-bindparam}
787
-	 *
788
-	 * Example:
789
-	 * <code>
790
-	 * $value = 2;
791
-	 * $q->eq( 'id', $q->bindValue( $value ) );
792
-	 * $stmt = $q->executeQuery(); // executed with 'id = 2'
793
-	 * </code>
794
-	 *
795
-	 * @license New BSD License
796
-	 * @link http://www.zetacomponents.org
797
-	 *
798
-	 * @param mixed $value
799
-	 * @param mixed $type
800
-	 * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
801
-	 *
802
-	 * @return IParameter
803
-	 * @since 8.2.0
804
-	 */
805
-	public function createNamedParameter($value, $type = self::PARAM_STR, $placeHolder = null);
806
-
807
-	/**
808
-	 * Creates a new positional parameter and bind the given value to it.
809
-	 *
810
-	 * Attention: If you are using positional parameters with the query builder you have
811
-	 * to be very careful to bind all parameters in the order they appear in the SQL
812
-	 * statement , otherwise they get bound in the wrong order which can lead to serious
813
-	 * bugs in your code.
814
-	 *
815
-	 * Example:
816
-	 * <code>
817
-	 *  $qb = $conn->getQueryBuilder();
818
-	 *  $qb->select('u.*')
819
-	 *     ->from('users', 'u')
820
-	 *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
821
-	 *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
822
-	 * </code>
823
-	 *
824
-	 * @param mixed $value
825
-	 * @param integer $type
826
-	 *
827
-	 * @return IParameter
828
-	 * @since 8.2.0
829
-	 */
830
-	public function createPositionalParameter($value, $type = self::PARAM_STR);
831
-
832
-	/**
833
-	 * Creates a new parameter
834
-	 *
835
-	 * Example:
836
-	 * <code>
837
-	 *  $qb = $conn->getQueryBuilder();
838
-	 *  $qb->select('u.*')
839
-	 *     ->from('users', 'u')
840
-	 *     ->where('u.username = ' . $qb->createParameter('name'))
841
-	 *     ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))
842
-	 * </code>
843
-	 *
844
-	 * @param string $name
845
-	 *
846
-	 * @return IParameter
847
-	 * @since 8.2.0
848
-	 */
849
-	public function createParameter($name);
850
-
851
-	/**
852
-	 * Creates a new function
853
-	 *
854
-	 * Attention: Column names inside the call have to be quoted before hand
855
-	 *
856
-	 * Example:
857
-	 * <code>
858
-	 *  $qb = $conn->getQueryBuilder();
859
-	 *  $qb->select($qb->createFunction('COUNT(*)'))
860
-	 *     ->from('users', 'u')
861
-	 *  echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u
862
-	 * </code>
863
-	 * <code>
864
-	 *  $qb = $conn->getQueryBuilder();
865
-	 *  $qb->select($qb->createFunction('COUNT(`column`)'))
866
-	 *     ->from('users', 'u')
867
-	 *  echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u
868
-	 * </code>
869
-	 *
870
-	 * @param string $call
871
-	 *
872
-	 * @return IQueryFunction
873
-	 * @since 8.2.0
874
-	 */
875
-	public function createFunction($call);
876
-
877
-	/**
878
-	 * Used to get the id of the last inserted element
879
-	 * @return int
880
-	 * @throws \BadMethodCallException When being called before an insert query has been run.
881
-	 * @since 9.0.0
882
-	 */
883
-	public function getLastInsertId();
884
-
885
-	/**
886
-	 * Returns the table name quoted and with database prefix as needed by the implementation
887
-	 *
888
-	 * @param string $table
889
-	 * @return string
890
-	 * @since 9.0.0
891
-	 */
892
-	public function getTableName($table);
893
-
894
-	/**
895
-	 * Returns the column name quoted and with table alias prefix as needed by the implementation
896
-	 *
897
-	 * @param string $column
898
-	 * @param string $tableAlias
899
-	 * @return string
900
-	 * @since 9.0.0
901
-	 */
902
-	public function getColumnName($column, $tableAlias = '');
36
+    /**
37
+     * @since 9.0.0
38
+     */
39
+    const PARAM_NULL = \PDO::PARAM_NULL;
40
+    /**
41
+     * @since 9.0.0
42
+     */
43
+    const PARAM_BOOL = \PDO::PARAM_BOOL;
44
+    /**
45
+     * @since 9.0.0
46
+     */
47
+    const PARAM_INT = \PDO::PARAM_INT;
48
+    /**
49
+     * @since 9.0.0
50
+     */
51
+    const PARAM_STR = \PDO::PARAM_STR;
52
+    /**
53
+     * @since 9.0.0
54
+     */
55
+    const PARAM_LOB = \PDO::PARAM_LOB;
56
+    /**
57
+     * @since 9.0.0
58
+     */
59
+    const PARAM_DATE = 'datetime';
60
+
61
+    /**
62
+     * @since 9.0.0
63
+     */
64
+    const PARAM_INT_ARRAY = Connection::PARAM_INT_ARRAY;
65
+    /**
66
+     * @since 9.0.0
67
+     */
68
+    const PARAM_STR_ARRAY = Connection::PARAM_STR_ARRAY;
69
+
70
+
71
+    /**
72
+     * Enable/disable automatic prefixing of table names with the oc_ prefix
73
+     *
74
+     * @param bool $enabled If set to true table names will be prefixed with the
75
+     * owncloud database prefix automatically.
76
+     * @since 8.2.0
77
+     */
78
+    public function automaticTablePrefix($enabled);
79
+
80
+    /**
81
+     * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
82
+     * This producer method is intended for convenient inline usage. Example:
83
+     *
84
+     * <code>
85
+     *     $qb = $conn->getQueryBuilder()
86
+     *         ->select('u')
87
+     *         ->from('users', 'u')
88
+     *         ->where($qb->expr()->eq('u.id', 1));
89
+     * </code>
90
+     *
91
+     * For more complex expression construction, consider storing the expression
92
+     * builder object in a local variable.
93
+     *
94
+     * @return \OCP\DB\QueryBuilder\IExpressionBuilder
95
+     * @since 8.2.0
96
+     */
97
+    public function expr();
98
+
99
+    /**
100
+     * Gets an FunctionBuilder used for object-oriented construction of query functions.
101
+     * This producer method is intended for convenient inline usage. Example:
102
+     *
103
+     * <code>
104
+     *     $qb = $conn->getQueryBuilder()
105
+     *         ->select('u')
106
+     *         ->from('users', 'u')
107
+     *         ->where($qb->fun()->md5('u.id'));
108
+     * </code>
109
+     *
110
+     * For more complex function construction, consider storing the function
111
+     * builder object in a local variable.
112
+     *
113
+     * @return \OCP\DB\QueryBuilder\IFunctionBuilder
114
+     * @since 12.0.0
115
+     */
116
+    public function func();
117
+
118
+    /**
119
+     * Gets the type of the currently built query.
120
+     *
121
+     * @return integer
122
+     * @since 8.2.0
123
+     */
124
+    public function getType();
125
+
126
+    /**
127
+     * Gets the associated DBAL Connection for this query builder.
128
+     *
129
+     * @return \OCP\IDBConnection
130
+     * @since 8.2.0
131
+     */
132
+    public function getConnection();
133
+
134
+    /**
135
+     * Gets the state of this query builder instance.
136
+     *
137
+     * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.
138
+     * @since 8.2.0
139
+     */
140
+    public function getState();
141
+
142
+    /**
143
+     * Executes this query using the bound parameters and their types.
144
+     *
145
+     * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
146
+     * for insert, update and delete statements.
147
+     *
148
+     * @return \Doctrine\DBAL\Driver\Statement|int
149
+     * @since 8.2.0
150
+     */
151
+    public function execute();
152
+
153
+    /**
154
+     * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
155
+     *
156
+     * <code>
157
+     *     $qb = $conn->getQueryBuilder()
158
+     *         ->select('u')
159
+     *         ->from('User', 'u')
160
+     *     echo $qb->getSQL(); // SELECT u FROM User u
161
+     * </code>
162
+     *
163
+     * @return string The SQL query string.
164
+     * @since 8.2.0
165
+     */
166
+    public function getSQL();
167
+
168
+    /**
169
+     * Sets a query parameter for the query being constructed.
170
+     *
171
+     * <code>
172
+     *     $qb = $conn->getQueryBuilder()
173
+     *         ->select('u')
174
+     *         ->from('users', 'u')
175
+     *         ->where('u.id = :user_id')
176
+     *         ->setParameter(':user_id', 1);
177
+     * </code>
178
+     *
179
+     * @param string|integer $key The parameter position or name.
180
+     * @param mixed $value The parameter value.
181
+     * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
182
+     *
183
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
184
+     * @since 8.2.0
185
+     */
186
+    public function setParameter($key, $value, $type = null);
187
+
188
+    /**
189
+     * Sets a collection of query parameters for the query being constructed.
190
+     *
191
+     * <code>
192
+     *     $qb = $conn->getQueryBuilder()
193
+     *         ->select('u')
194
+     *         ->from('users', 'u')
195
+     *         ->where('u.id = :user_id1 OR u.id = :user_id2')
196
+     *         ->setParameters(array(
197
+     *             ':user_id1' => 1,
198
+     *             ':user_id2' => 2
199
+     *         ));
200
+     * </code>
201
+     *
202
+     * @param array $params The query parameters to set.
203
+     * @param array $types The query parameters types to set.
204
+     *
205
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
206
+     * @since 8.2.0
207
+     */
208
+    public function setParameters(array $params, array $types = array());
209
+
210
+    /**
211
+     * Gets all defined query parameters for the query being constructed indexed by parameter index or name.
212
+     *
213
+     * @return array The currently defined query parameters indexed by parameter index or name.
214
+     * @since 8.2.0
215
+     */
216
+    public function getParameters();
217
+
218
+    /**
219
+     * Gets a (previously set) query parameter of the query being constructed.
220
+     *
221
+     * @param mixed $key The key (index or name) of the bound parameter.
222
+     *
223
+     * @return mixed The value of the bound parameter.
224
+     * @since 8.2.0
225
+     */
226
+    public function getParameter($key);
227
+
228
+    /**
229
+     * Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
230
+     *
231
+     * @return array The currently defined query parameter types indexed by parameter index or name.
232
+     * @since 8.2.0
233
+     */
234
+    public function getParameterTypes();
235
+
236
+    /**
237
+     * Gets a (previously set) query parameter type of the query being constructed.
238
+     *
239
+     * @param mixed $key The key (index or name) of the bound parameter type.
240
+     *
241
+     * @return mixed The value of the bound parameter type.
242
+     * @since 8.2.0
243
+     */
244
+    public function getParameterType($key);
245
+
246
+    /**
247
+     * Sets the position of the first result to retrieve (the "offset").
248
+     *
249
+     * @param integer $firstResult The first result to return.
250
+     *
251
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
252
+     * @since 8.2.0
253
+     */
254
+    public function setFirstResult($firstResult);
255
+
256
+    /**
257
+     * Gets the position of the first result the query object was set to retrieve (the "offset").
258
+     * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
259
+     *
260
+     * @return integer The position of the first result.
261
+     * @since 8.2.0
262
+     */
263
+    public function getFirstResult();
264
+
265
+    /**
266
+     * Sets the maximum number of results to retrieve (the "limit").
267
+     *
268
+     * @param integer $maxResults The maximum number of results to retrieve.
269
+     *
270
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
271
+     * @since 8.2.0
272
+     */
273
+    public function setMaxResults($maxResults);
274
+
275
+    /**
276
+     * Gets the maximum number of results the query object was set to retrieve (the "limit").
277
+     * Returns NULL if {@link setMaxResults} was not applied to this query builder.
278
+     *
279
+     * @return integer The maximum number of results.
280
+     * @since 8.2.0
281
+     */
282
+    public function getMaxResults();
283
+
284
+    /**
285
+     * Specifies an item that is to be returned in the query result.
286
+     * Replaces any previously specified selections, if any.
287
+     *
288
+     * <code>
289
+     *     $qb = $conn->getQueryBuilder()
290
+     *         ->select('u.id', 'p.id')
291
+     *         ->from('users', 'u')
292
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
293
+     * </code>
294
+     *
295
+     * @param mixed ...$selects The selection expressions.
296
+     *
297
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
298
+     * @since 8.2.0
299
+     */
300
+    public function select(...$selects);
301
+
302
+    /**
303
+     * Specifies an item that is to be returned with a different name in the query result.
304
+     *
305
+     * <code>
306
+     *     $qb = $conn->getQueryBuilder()
307
+     *         ->selectAlias('u.id', 'user_id')
308
+     *         ->from('users', 'u')
309
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
310
+     * </code>
311
+     *
312
+     * @param mixed $select The selection expressions.
313
+     * @param string $alias The column alias used in the constructed query.
314
+     *
315
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
316
+     * @since 8.2.1
317
+     */
318
+    public function selectAlias($select, $alias);
319
+
320
+    /**
321
+     * Specifies an item that is to be returned uniquely in the query result.
322
+     *
323
+     * <code>
324
+     *     $qb = $conn->getQueryBuilder()
325
+     *         ->selectDistinct('type')
326
+     *         ->from('users');
327
+     * </code>
328
+     *
329
+     * @param mixed $select The selection expressions.
330
+     *
331
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
332
+     * @since 9.0.0
333
+     */
334
+    public function selectDistinct($select);
335
+
336
+    /**
337
+     * Adds an item that is to be returned in the query result.
338
+     *
339
+     * <code>
340
+     *     $qb = $conn->getQueryBuilder()
341
+     *         ->select('u.id')
342
+     *         ->addSelect('p.id')
343
+     *         ->from('users', 'u')
344
+     *         ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
345
+     * </code>
346
+     *
347
+     * @param mixed ...$select The selection expression.
348
+     *
349
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
350
+     * @since 8.2.0
351
+     */
352
+    public function addSelect(...$select);
353
+
354
+    /**
355
+     * Turns the query being built into a bulk delete query that ranges over
356
+     * a certain table.
357
+     *
358
+     * <code>
359
+     *     $qb = $conn->getQueryBuilder()
360
+     *         ->delete('users', 'u')
361
+     *         ->where('u.id = :user_id');
362
+     *         ->setParameter(':user_id', 1);
363
+     * </code>
364
+     *
365
+     * @param string $delete The table whose rows are subject to the deletion.
366
+     * @param string $alias The table alias used in the constructed query.
367
+     *
368
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
369
+     * @since 8.2.0
370
+     */
371
+    public function delete($delete = null, $alias = null);
372
+
373
+    /**
374
+     * Turns the query being built into a bulk update query that ranges over
375
+     * a certain table
376
+     *
377
+     * <code>
378
+     *     $qb = $conn->getQueryBuilder()
379
+     *         ->update('users', 'u')
380
+     *         ->set('u.password', md5('password'))
381
+     *         ->where('u.id = ?');
382
+     * </code>
383
+     *
384
+     * @param string $update The table whose rows are subject to the update.
385
+     * @param string $alias The table alias used in the constructed query.
386
+     *
387
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
388
+     * @since 8.2.0
389
+     */
390
+    public function update($update = null, $alias = null);
391
+
392
+    /**
393
+     * Turns the query being built into an insert query that inserts into
394
+     * a certain table
395
+     *
396
+     * <code>
397
+     *     $qb = $conn->getQueryBuilder()
398
+     *         ->insert('users')
399
+     *         ->values(
400
+     *             array(
401
+     *                 'name' => '?',
402
+     *                 'password' => '?'
403
+     *             )
404
+     *         );
405
+     * </code>
406
+     *
407
+     * @param string $insert The table into which the rows should be inserted.
408
+     *
409
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
410
+     * @since 8.2.0
411
+     */
412
+    public function insert($insert = null);
413
+
414
+    /**
415
+     * Creates and adds a query root corresponding to the table identified by the
416
+     * given alias, forming a cartesian product with any existing query roots.
417
+     *
418
+     * <code>
419
+     *     $qb = $conn->getQueryBuilder()
420
+     *         ->select('u.id')
421
+     *         ->from('users', 'u')
422
+     * </code>
423
+     *
424
+     * @param string $from The table.
425
+     * @param string|null $alias The alias of the table.
426
+     *
427
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
428
+     * @since 8.2.0
429
+     */
430
+    public function from($from, $alias = null);
431
+
432
+    /**
433
+     * Creates and adds a join to the query.
434
+     *
435
+     * <code>
436
+     *     $qb = $conn->getQueryBuilder()
437
+     *         ->select('u.name')
438
+     *         ->from('users', 'u')
439
+     *         ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
440
+     * </code>
441
+     *
442
+     * @param string $fromAlias The alias that points to a from clause.
443
+     * @param string $join The table name to join.
444
+     * @param string $alias The alias of the join table.
445
+     * @param string $condition The condition for the join.
446
+     *
447
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
448
+     * @since 8.2.0
449
+     */
450
+    public function join($fromAlias, $join, $alias, $condition = null);
451
+
452
+    /**
453
+     * Creates and adds a join to the query.
454
+     *
455
+     * <code>
456
+     *     $qb = $conn->getQueryBuilder()
457
+     *         ->select('u.name')
458
+     *         ->from('users', 'u')
459
+     *         ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
460
+     * </code>
461
+     *
462
+     * @param string $fromAlias The alias that points to a from clause.
463
+     * @param string $join The table name to join.
464
+     * @param string $alias The alias of the join table.
465
+     * @param string $condition The condition for the join.
466
+     *
467
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
468
+     * @since 8.2.0
469
+     */
470
+    public function innerJoin($fromAlias, $join, $alias, $condition = null);
471
+
472
+    /**
473
+     * Creates and adds a left join to the query.
474
+     *
475
+     * <code>
476
+     *     $qb = $conn->getQueryBuilder()
477
+     *         ->select('u.name')
478
+     *         ->from('users', 'u')
479
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
480
+     * </code>
481
+     *
482
+     * @param string $fromAlias The alias that points to a from clause.
483
+     * @param string $join The table name to join.
484
+     * @param string $alias The alias of the join table.
485
+     * @param string $condition The condition for the join.
486
+     *
487
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
488
+     * @since 8.2.0
489
+     */
490
+    public function leftJoin($fromAlias, $join, $alias, $condition = null);
491
+
492
+    /**
493
+     * Creates and adds a right join to the query.
494
+     *
495
+     * <code>
496
+     *     $qb = $conn->getQueryBuilder()
497
+     *         ->select('u.name')
498
+     *         ->from('users', 'u')
499
+     *         ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
500
+     * </code>
501
+     *
502
+     * @param string $fromAlias The alias that points to a from clause.
503
+     * @param string $join The table name to join.
504
+     * @param string $alias The alias of the join table.
505
+     * @param string $condition The condition for the join.
506
+     *
507
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
508
+     * @since 8.2.0
509
+     */
510
+    public function rightJoin($fromAlias, $join, $alias, $condition = null);
511
+
512
+    /**
513
+     * Sets a new value for a column in a bulk update query.
514
+     *
515
+     * <code>
516
+     *     $qb = $conn->getQueryBuilder()
517
+     *         ->update('users', 'u')
518
+     *         ->set('u.password', md5('password'))
519
+     *         ->where('u.id = ?');
520
+     * </code>
521
+     *
522
+     * @param string $key The column to set.
523
+     * @param string $value The value, expression, placeholder, etc.
524
+     *
525
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
526
+     * @since 8.2.0
527
+     */
528
+    public function set($key, $value);
529
+
530
+    /**
531
+     * Specifies one or more restrictions to the query result.
532
+     * Replaces any previously specified restrictions, if any.
533
+     *
534
+     * <code>
535
+     *     $qb = $conn->getQueryBuilder()
536
+     *         ->select('u.name')
537
+     *         ->from('users', 'u')
538
+     *         ->where('u.id = ?');
539
+     *
540
+     *     // You can optionally programatically build and/or expressions
541
+     *     $qb = $conn->getQueryBuilder();
542
+     *
543
+     *     $or = $qb->expr()->orx();
544
+     *     $or->add($qb->expr()->eq('u.id', 1));
545
+     *     $or->add($qb->expr()->eq('u.id', 2));
546
+     *
547
+     *     $qb->update('users', 'u')
548
+     *         ->set('u.password', md5('password'))
549
+     *         ->where($or);
550
+     * </code>
551
+     *
552
+     * @param mixed $predicates The restriction predicates.
553
+     *
554
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
555
+     * @since 8.2.0
556
+     */
557
+    public function where(...$predicates);
558
+
559
+    /**
560
+     * Adds one or more restrictions to the query results, forming a logical
561
+     * conjunction with any previously specified restrictions.
562
+     *
563
+     * <code>
564
+     *     $qb = $conn->getQueryBuilder()
565
+     *         ->select('u')
566
+     *         ->from('users', 'u')
567
+     *         ->where('u.username LIKE ?')
568
+     *         ->andWhere('u.is_active = 1');
569
+     * </code>
570
+     *
571
+     * @param mixed ...$where The query restrictions.
572
+     *
573
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
574
+     *
575
+     * @see where()
576
+     * @since 8.2.0
577
+     */
578
+    public function andWhere(...$where);
579
+
580
+    /**
581
+     * Adds one or more restrictions to the query results, forming a logical
582
+     * disjunction with any previously specified restrictions.
583
+     *
584
+     * <code>
585
+     *     $qb = $conn->getQueryBuilder()
586
+     *         ->select('u.name')
587
+     *         ->from('users', 'u')
588
+     *         ->where('u.id = 1')
589
+     *         ->orWhere('u.id = 2');
590
+     * </code>
591
+     *
592
+     * @param mixed ...$where The WHERE statement.
593
+     *
594
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
595
+     *
596
+     * @see where()
597
+     * @since 8.2.0
598
+     */
599
+    public function orWhere(...$where);
600
+
601
+    /**
602
+     * Specifies a grouping over the results of the query.
603
+     * Replaces any previously specified groupings, if any.
604
+     *
605
+     * <code>
606
+     *     $qb = $conn->getQueryBuilder()
607
+     *         ->select('u.name')
608
+     *         ->from('users', 'u')
609
+     *         ->groupBy('u.id');
610
+     * </code>
611
+     *
612
+     * @param mixed ...$groupBys The grouping expression.
613
+     *
614
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
615
+     * @since 8.2.0
616
+     */
617
+    public function groupBy(...$groupBys);
618
+
619
+    /**
620
+     * Adds a grouping expression to the query.
621
+     *
622
+     * <code>
623
+     *     $qb = $conn->getQueryBuilder()
624
+     *         ->select('u.name')
625
+     *         ->from('users', 'u')
626
+     *         ->groupBy('u.lastLogin');
627
+     *         ->addGroupBy('u.createdAt')
628
+     * </code>
629
+     *
630
+     * @param mixed ...$groupBy The grouping expression.
631
+     *
632
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
633
+     * @since 8.2.0
634
+     */
635
+    public function addGroupBy(...$groupBy);
636
+
637
+    /**
638
+     * Sets a value for a column in an insert query.
639
+     *
640
+     * <code>
641
+     *     $qb = $conn->getQueryBuilder()
642
+     *         ->insert('users')
643
+     *         ->values(
644
+     *             array(
645
+     *                 'name' => '?'
646
+     *             )
647
+     *         )
648
+     *         ->setValue('password', '?');
649
+     * </code>
650
+     *
651
+     * @param string $column The column into which the value should be inserted.
652
+     * @param string $value The value that should be inserted into the column.
653
+     *
654
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
655
+     * @since 8.2.0
656
+     */
657
+    public function setValue($column, $value);
658
+
659
+    /**
660
+     * Specifies values for an insert query indexed by column names.
661
+     * Replaces any previous values, if any.
662
+     *
663
+     * <code>
664
+     *     $qb = $conn->getQueryBuilder()
665
+     *         ->insert('users')
666
+     *         ->values(
667
+     *             array(
668
+     *                 'name' => '?',
669
+     *                 'password' => '?'
670
+     *             )
671
+     *         );
672
+     * </code>
673
+     *
674
+     * @param array $values The values to specify for the insert query indexed by column names.
675
+     *
676
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
677
+     * @since 8.2.0
678
+     */
679
+    public function values(array $values);
680
+
681
+    /**
682
+     * Specifies a restriction over the groups of the query.
683
+     * Replaces any previous having restrictions, if any.
684
+     *
685
+     * @param mixed ...$having The restriction over the groups.
686
+     *
687
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
688
+     * @since 8.2.0
689
+     */
690
+    public function having(...$having);
691
+
692
+    /**
693
+     * Adds a restriction over the groups of the query, forming a logical
694
+     * conjunction with any existing having restrictions.
695
+     *
696
+     * @param mixed ...$having The restriction to append.
697
+     *
698
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
699
+     * @since 8.2.0
700
+     */
701
+    public function andHaving(...$having);
702
+
703
+    /**
704
+     * Adds a restriction over the groups of the query, forming a logical
705
+     * disjunction with any existing having restrictions.
706
+     *
707
+     * @param mixed ...$having The restriction to add.
708
+     *
709
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
710
+     * @since 8.2.0
711
+     */
712
+    public function orHaving(...$having);
713
+
714
+    /**
715
+     * Specifies an ordering for the query results.
716
+     * Replaces any previously specified orderings, if any.
717
+     *
718
+     * @param string $sort The ordering expression.
719
+     * @param string $order The ordering direction.
720
+     *
721
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
722
+     * @since 8.2.0
723
+     */
724
+    public function orderBy($sort, $order = null);
725
+
726
+    /**
727
+     * Adds an ordering to the query results.
728
+     *
729
+     * @param string $sort The ordering expression.
730
+     * @param string $order The ordering direction.
731
+     *
732
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
733
+     * @since 8.2.0
734
+     */
735
+    public function addOrderBy($sort, $order = null);
736
+
737
+    /**
738
+     * Gets a query part by its name.
739
+     *
740
+     * @param string $queryPartName
741
+     *
742
+     * @return mixed
743
+     * @since 8.2.0
744
+     */
745
+    public function getQueryPart($queryPartName);
746
+
747
+    /**
748
+     * Gets all query parts.
749
+     *
750
+     * @return array
751
+     * @since 8.2.0
752
+     */
753
+    public function getQueryParts();
754
+
755
+    /**
756
+     * Resets SQL parts.
757
+     *
758
+     * @param array|null $queryPartNames
759
+     *
760
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
761
+     * @since 8.2.0
762
+     */
763
+    public function resetQueryParts($queryPartNames = null);
764
+
765
+    /**
766
+     * Resets a single SQL part.
767
+     *
768
+     * @param string $queryPartName
769
+     *
770
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
771
+     * @since 8.2.0
772
+     */
773
+    public function resetQueryPart($queryPartName);
774
+
775
+    /**
776
+     * Creates a new named parameter and bind the value $value to it.
777
+     *
778
+     * This method provides a shortcut for PDOStatement::bindValue
779
+     * when using prepared statements.
780
+     *
781
+     * The parameter $value specifies the value that you want to bind. If
782
+     * $placeholder is not provided bindValue() will automatically create a
783
+     * placeholder for you. An automatic placeholder will be of the name
784
+     * ':dcValue1', ':dcValue2' etc.
785
+     *
786
+     * For more information see {@link http://php.net/pdostatement-bindparam}
787
+     *
788
+     * Example:
789
+     * <code>
790
+     * $value = 2;
791
+     * $q->eq( 'id', $q->bindValue( $value ) );
792
+     * $stmt = $q->executeQuery(); // executed with 'id = 2'
793
+     * </code>
794
+     *
795
+     * @license New BSD License
796
+     * @link http://www.zetacomponents.org
797
+     *
798
+     * @param mixed $value
799
+     * @param mixed $type
800
+     * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
801
+     *
802
+     * @return IParameter
803
+     * @since 8.2.0
804
+     */
805
+    public function createNamedParameter($value, $type = self::PARAM_STR, $placeHolder = null);
806
+
807
+    /**
808
+     * Creates a new positional parameter and bind the given value to it.
809
+     *
810
+     * Attention: If you are using positional parameters with the query builder you have
811
+     * to be very careful to bind all parameters in the order they appear in the SQL
812
+     * statement , otherwise they get bound in the wrong order which can lead to serious
813
+     * bugs in your code.
814
+     *
815
+     * Example:
816
+     * <code>
817
+     *  $qb = $conn->getQueryBuilder();
818
+     *  $qb->select('u.*')
819
+     *     ->from('users', 'u')
820
+     *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
821
+     *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
822
+     * </code>
823
+     *
824
+     * @param mixed $value
825
+     * @param integer $type
826
+     *
827
+     * @return IParameter
828
+     * @since 8.2.0
829
+     */
830
+    public function createPositionalParameter($value, $type = self::PARAM_STR);
831
+
832
+    /**
833
+     * Creates a new parameter
834
+     *
835
+     * Example:
836
+     * <code>
837
+     *  $qb = $conn->getQueryBuilder();
838
+     *  $qb->select('u.*')
839
+     *     ->from('users', 'u')
840
+     *     ->where('u.username = ' . $qb->createParameter('name'))
841
+     *     ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))
842
+     * </code>
843
+     *
844
+     * @param string $name
845
+     *
846
+     * @return IParameter
847
+     * @since 8.2.0
848
+     */
849
+    public function createParameter($name);
850
+
851
+    /**
852
+     * Creates a new function
853
+     *
854
+     * Attention: Column names inside the call have to be quoted before hand
855
+     *
856
+     * Example:
857
+     * <code>
858
+     *  $qb = $conn->getQueryBuilder();
859
+     *  $qb->select($qb->createFunction('COUNT(*)'))
860
+     *     ->from('users', 'u')
861
+     *  echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u
862
+     * </code>
863
+     * <code>
864
+     *  $qb = $conn->getQueryBuilder();
865
+     *  $qb->select($qb->createFunction('COUNT(`column`)'))
866
+     *     ->from('users', 'u')
867
+     *  echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u
868
+     * </code>
869
+     *
870
+     * @param string $call
871
+     *
872
+     * @return IQueryFunction
873
+     * @since 8.2.0
874
+     */
875
+    public function createFunction($call);
876
+
877
+    /**
878
+     * Used to get the id of the last inserted element
879
+     * @return int
880
+     * @throws \BadMethodCallException When being called before an insert query has been run.
881
+     * @since 9.0.0
882
+     */
883
+    public function getLastInsertId();
884
+
885
+    /**
886
+     * Returns the table name quoted and with database prefix as needed by the implementation
887
+     *
888
+     * @param string $table
889
+     * @return string
890
+     * @since 9.0.0
891
+     */
892
+    public function getTableName($table);
893
+
894
+    /**
895
+     * Returns the column name quoted and with table alias prefix as needed by the implementation
896
+     *
897
+     * @param string $column
898
+     * @param string $tableAlias
899
+     * @return string
900
+     * @since 9.0.0
901
+     */
902
+    public function getColumnName($column, $tableAlias = '');
903 903
 }
Please login to merge, or discard this patch.
lib/public/DB/QueryBuilder/IExpressionBuilder.php 1 patch
Indentation   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -32,336 +32,336 @@
 block discarded – undo
32 32
  * @since 8.2.0
33 33
  */
34 34
 interface IExpressionBuilder {
35
-	/**
36
-	 * @since 9.0.0
37
-	 */
38
-	const EQ  = ExpressionBuilder::EQ;
39
-	/**
40
-	 * @since 9.0.0
41
-	 */
42
-	const NEQ = ExpressionBuilder::NEQ;
43
-	/**
44
-	 * @since 9.0.0
45
-	 */
46
-	const LT  = ExpressionBuilder::LT;
47
-	/**
48
-	 * @since 9.0.0
49
-	 */
50
-	const LTE = ExpressionBuilder::LTE;
51
-	/**
52
-	 * @since 9.0.0
53
-	 */
54
-	const GT  = ExpressionBuilder::GT;
55
-	/**
56
-	 * @since 9.0.0
57
-	 */
58
-	const GTE = ExpressionBuilder::GTE;
35
+    /**
36
+     * @since 9.0.0
37
+     */
38
+    const EQ  = ExpressionBuilder::EQ;
39
+    /**
40
+     * @since 9.0.0
41
+     */
42
+    const NEQ = ExpressionBuilder::NEQ;
43
+    /**
44
+     * @since 9.0.0
45
+     */
46
+    const LT  = ExpressionBuilder::LT;
47
+    /**
48
+     * @since 9.0.0
49
+     */
50
+    const LTE = ExpressionBuilder::LTE;
51
+    /**
52
+     * @since 9.0.0
53
+     */
54
+    const GT  = ExpressionBuilder::GT;
55
+    /**
56
+     * @since 9.0.0
57
+     */
58
+    const GTE = ExpressionBuilder::GTE;
59 59
 
60
-	/**
61
-	 * Creates a conjunction of the given boolean expressions.
62
-	 *
63
-	 * Example:
64
-	 *
65
-	 *     [php]
66
-	 *     // (u.type = ?) AND (u.role = ?)
67
-	 *     $expr->andX('u.type = ?', 'u.role = ?'));
68
-	 *
69
-	 * @param mixed ...$x Optional clause. Defaults = null, but requires
70
-	 *                 at least one defined when converting to string.
71
-	 *
72
-	 * @return \OCP\DB\QueryBuilder\ICompositeExpression
73
-	 * @since 8.2.0
74
-	 */
75
-	public function andX(...$x);
60
+    /**
61
+     * Creates a conjunction of the given boolean expressions.
62
+     *
63
+     * Example:
64
+     *
65
+     *     [php]
66
+     *     // (u.type = ?) AND (u.role = ?)
67
+     *     $expr->andX('u.type = ?', 'u.role = ?'));
68
+     *
69
+     * @param mixed ...$x Optional clause. Defaults = null, but requires
70
+     *                 at least one defined when converting to string.
71
+     *
72
+     * @return \OCP\DB\QueryBuilder\ICompositeExpression
73
+     * @since 8.2.0
74
+     */
75
+    public function andX(...$x);
76 76
 
77
-	/**
78
-	 * Creates a disjunction of the given boolean expressions.
79
-	 *
80
-	 * Example:
81
-	 *
82
-	 *     [php]
83
-	 *     // (u.type = ?) OR (u.role = ?)
84
-	 *     $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?'));
85
-	 *
86
-	 * @param mixed ...$x Optional clause. Defaults = null, but requires
87
-	 *                 at least one defined when converting to string.
88
-	 *
89
-	 * @return \OCP\DB\QueryBuilder\ICompositeExpression
90
-	 * @since 8.2.0
91
-	 */
92
-	public function orX(...$x);
77
+    /**
78
+     * Creates a disjunction of the given boolean expressions.
79
+     *
80
+     * Example:
81
+     *
82
+     *     [php]
83
+     *     // (u.type = ?) OR (u.role = ?)
84
+     *     $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?'));
85
+     *
86
+     * @param mixed ...$x Optional clause. Defaults = null, but requires
87
+     *                 at least one defined when converting to string.
88
+     *
89
+     * @return \OCP\DB\QueryBuilder\ICompositeExpression
90
+     * @since 8.2.0
91
+     */
92
+    public function orX(...$x);
93 93
 
94
-	/**
95
-	 * Creates a comparison expression.
96
-	 *
97
-	 * @param mixed $x The left expression.
98
-	 * @param string $operator One of the IExpressionBuilder::* constants.
99
-	 * @param mixed $y The right expression.
100
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
101
-	 *                  required when comparing text fields for oci compatibility
102
-	 *
103
-	 * @return string
104
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
105
-	 */
106
-	public function comparison($x, $operator, $y, $type = null);
94
+    /**
95
+     * Creates a comparison expression.
96
+     *
97
+     * @param mixed $x The left expression.
98
+     * @param string $operator One of the IExpressionBuilder::* constants.
99
+     * @param mixed $y The right expression.
100
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
101
+     *                  required when comparing text fields for oci compatibility
102
+     *
103
+     * @return string
104
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
105
+     */
106
+    public function comparison($x, $operator, $y, $type = null);
107 107
 
108
-	/**
109
-	 * Creates an equality comparison expression with the given arguments.
110
-	 *
111
-	 * First argument is considered the left expression and the second is the right expression.
112
-	 * When converted to string, it will generated a <left expr> = <right expr>. Example:
113
-	 *
114
-	 *     [php]
115
-	 *     // u.id = ?
116
-	 *     $expr->eq('u.id', '?');
117
-	 *
118
-	 * @param mixed $x The left expression.
119
-	 * @param mixed $y The right expression.
120
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
121
-	 *                  required when comparing text fields for oci compatibility
122
-	 *
123
-	 * @return string
124
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
125
-	 */
126
-	public function eq($x, $y, $type = null);
108
+    /**
109
+     * Creates an equality comparison expression with the given arguments.
110
+     *
111
+     * First argument is considered the left expression and the second is the right expression.
112
+     * When converted to string, it will generated a <left expr> = <right expr>. Example:
113
+     *
114
+     *     [php]
115
+     *     // u.id = ?
116
+     *     $expr->eq('u.id', '?');
117
+     *
118
+     * @param mixed $x The left expression.
119
+     * @param mixed $y The right expression.
120
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
121
+     *                  required when comparing text fields for oci compatibility
122
+     *
123
+     * @return string
124
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
125
+     */
126
+    public function eq($x, $y, $type = null);
127 127
 
128
-	/**
129
-	 * Creates a non equality comparison expression with the given arguments.
130
-	 * First argument is considered the left expression and the second is the right expression.
131
-	 * When converted to string, it will generated a <left expr> <> <right expr>. Example:
132
-	 *
133
-	 *     [php]
134
-	 *     // u.id <> 1
135
-	 *     $q->where($q->expr()->neq('u.id', '1'));
136
-	 *
137
-	 * @param mixed $x The left expression.
138
-	 * @param mixed $y The right expression.
139
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
140
-	 *                  required when comparing text fields for oci compatibility
141
-	 *
142
-	 * @return string
143
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
144
-	 */
145
-	public function neq($x, $y, $type = null);
128
+    /**
129
+     * Creates a non equality comparison expression with the given arguments.
130
+     * First argument is considered the left expression and the second is the right expression.
131
+     * When converted to string, it will generated a <left expr> <> <right expr>. Example:
132
+     *
133
+     *     [php]
134
+     *     // u.id <> 1
135
+     *     $q->where($q->expr()->neq('u.id', '1'));
136
+     *
137
+     * @param mixed $x The left expression.
138
+     * @param mixed $y The right expression.
139
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
140
+     *                  required when comparing text fields for oci compatibility
141
+     *
142
+     * @return string
143
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
144
+     */
145
+    public function neq($x, $y, $type = null);
146 146
 
147
-	/**
148
-	 * Creates a lower-than comparison expression with the given arguments.
149
-	 * First argument is considered the left expression and the second is the right expression.
150
-	 * When converted to string, it will generated a <left expr> < <right expr>. Example:
151
-	 *
152
-	 *     [php]
153
-	 *     // u.id < ?
154
-	 *     $q->where($q->expr()->lt('u.id', '?'));
155
-	 *
156
-	 * @param mixed $x The left expression.
157
-	 * @param mixed $y The right expression.
158
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
159
-	 *                  required when comparing text fields for oci compatibility
160
-	 *
161
-	 * @return string
162
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
163
-	 */
164
-	public function lt($x, $y, $type = null);
147
+    /**
148
+     * Creates a lower-than comparison expression with the given arguments.
149
+     * First argument is considered the left expression and the second is the right expression.
150
+     * When converted to string, it will generated a <left expr> < <right expr>. Example:
151
+     *
152
+     *     [php]
153
+     *     // u.id < ?
154
+     *     $q->where($q->expr()->lt('u.id', '?'));
155
+     *
156
+     * @param mixed $x The left expression.
157
+     * @param mixed $y The right expression.
158
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
159
+     *                  required when comparing text fields for oci compatibility
160
+     *
161
+     * @return string
162
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
163
+     */
164
+    public function lt($x, $y, $type = null);
165 165
 
166
-	/**
167
-	 * Creates a lower-than-equal comparison expression with the given arguments.
168
-	 * First argument is considered the left expression and the second is the right expression.
169
-	 * When converted to string, it will generated a <left expr> <= <right expr>. Example:
170
-	 *
171
-	 *     [php]
172
-	 *     // u.id <= ?
173
-	 *     $q->where($q->expr()->lte('u.id', '?'));
174
-	 *
175
-	 * @param mixed $x The left expression.
176
-	 * @param mixed $y The right expression.
177
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
178
-	 *                  required when comparing text fields for oci compatibility
179
-	 *
180
-	 * @return string
181
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
182
-	 */
183
-	public function lte($x, $y, $type = null);
166
+    /**
167
+     * Creates a lower-than-equal comparison expression with the given arguments.
168
+     * First argument is considered the left expression and the second is the right expression.
169
+     * When converted to string, it will generated a <left expr> <= <right expr>. Example:
170
+     *
171
+     *     [php]
172
+     *     // u.id <= ?
173
+     *     $q->where($q->expr()->lte('u.id', '?'));
174
+     *
175
+     * @param mixed $x The left expression.
176
+     * @param mixed $y The right expression.
177
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
178
+     *                  required when comparing text fields for oci compatibility
179
+     *
180
+     * @return string
181
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
182
+     */
183
+    public function lte($x, $y, $type = null);
184 184
 
185
-	/**
186
-	 * Creates a greater-than comparison expression with the given arguments.
187
-	 * First argument is considered the left expression and the second is the right expression.
188
-	 * When converted to string, it will generated a <left expr> > <right expr>. Example:
189
-	 *
190
-	 *     [php]
191
-	 *     // u.id > ?
192
-	 *     $q->where($q->expr()->gt('u.id', '?'));
193
-	 *
194
-	 * @param mixed $x The left expression.
195
-	 * @param mixed $y The right expression.
196
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
197
-	 *                  required when comparing text fields for oci compatibility
198
-	 *
199
-	 * @return string
200
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
201
-	 */
202
-	public function gt($x, $y, $type = null);
185
+    /**
186
+     * Creates a greater-than comparison expression with the given arguments.
187
+     * First argument is considered the left expression and the second is the right expression.
188
+     * When converted to string, it will generated a <left expr> > <right expr>. Example:
189
+     *
190
+     *     [php]
191
+     *     // u.id > ?
192
+     *     $q->where($q->expr()->gt('u.id', '?'));
193
+     *
194
+     * @param mixed $x The left expression.
195
+     * @param mixed $y The right expression.
196
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
197
+     *                  required when comparing text fields for oci compatibility
198
+     *
199
+     * @return string
200
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
201
+     */
202
+    public function gt($x, $y, $type = null);
203 203
 
204
-	/**
205
-	 * Creates a greater-than-equal comparison expression with the given arguments.
206
-	 * First argument is considered the left expression and the second is the right expression.
207
-	 * When converted to string, it will generated a <left expr> >= <right expr>. Example:
208
-	 *
209
-	 *     [php]
210
-	 *     // u.id >= ?
211
-	 *     $q->where($q->expr()->gte('u.id', '?'));
212
-	 *
213
-	 * @param mixed $x The left expression.
214
-	 * @param mixed $y The right expression.
215
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
216
-	 *                  required when comparing text fields for oci compatibility
217
-	 *
218
-	 * @return string
219
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
220
-	 */
221
-	public function gte($x, $y, $type = null);
204
+    /**
205
+     * Creates a greater-than-equal comparison expression with the given arguments.
206
+     * First argument is considered the left expression and the second is the right expression.
207
+     * When converted to string, it will generated a <left expr> >= <right expr>. Example:
208
+     *
209
+     *     [php]
210
+     *     // u.id >= ?
211
+     *     $q->where($q->expr()->gte('u.id', '?'));
212
+     *
213
+     * @param mixed $x The left expression.
214
+     * @param mixed $y The right expression.
215
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
216
+     *                  required when comparing text fields for oci compatibility
217
+     *
218
+     * @return string
219
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
220
+     */
221
+    public function gte($x, $y, $type = null);
222 222
 
223
-	/**
224
-	 * Creates an IS NULL expression with the given arguments.
225
-	 *
226
-	 * @param string $x The field in string format to be restricted by IS NULL.
227
-	 *
228
-	 * @return string
229
-	 * @since 8.2.0
230
-	 */
231
-	public function isNull($x);
223
+    /**
224
+     * Creates an IS NULL expression with the given arguments.
225
+     *
226
+     * @param string $x The field in string format to be restricted by IS NULL.
227
+     *
228
+     * @return string
229
+     * @since 8.2.0
230
+     */
231
+    public function isNull($x);
232 232
 
233
-	/**
234
-	 * Creates an IS NOT NULL expression with the given arguments.
235
-	 *
236
-	 * @param string $x The field in string format to be restricted by IS NOT NULL.
237
-	 *
238
-	 * @return string
239
-	 * @since 8.2.0
240
-	 */
241
-	public function isNotNull($x);
233
+    /**
234
+     * Creates an IS NOT NULL expression with the given arguments.
235
+     *
236
+     * @param string $x The field in string format to be restricted by IS NOT NULL.
237
+     *
238
+     * @return string
239
+     * @since 8.2.0
240
+     */
241
+    public function isNotNull($x);
242 242
 
243
-	/**
244
-	 * Creates a LIKE() comparison expression with the given arguments.
245
-	 *
246
-	 * @param string $x Field in string format to be inspected by LIKE() comparison.
247
-	 * @param mixed $y Argument to be used in LIKE() comparison.
248
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
249
-	 *                  required when comparing text fields for oci compatibility
250
-	 *
251
-	 * @return string
252
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
253
-	 */
254
-	public function like($x, $y, $type = null);
243
+    /**
244
+     * Creates a LIKE() comparison expression with the given arguments.
245
+     *
246
+     * @param string $x Field in string format to be inspected by LIKE() comparison.
247
+     * @param mixed $y Argument to be used in LIKE() comparison.
248
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
249
+     *                  required when comparing text fields for oci compatibility
250
+     *
251
+     * @return string
252
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
253
+     */
254
+    public function like($x, $y, $type = null);
255 255
 
256
-	/**
257
-	 * Creates a NOT LIKE() comparison expression with the given arguments.
258
-	 *
259
-	 * @param string $x Field in string format to be inspected by NOT LIKE() comparison.
260
-	 * @param mixed $y Argument to be used in NOT LIKE() comparison.
261
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
262
-	 *                  required when comparing text fields for oci compatibility
263
-	 *
264
-	 * @return string
265
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
266
-	 */
267
-	public function notLike($x, $y, $type = null);
256
+    /**
257
+     * Creates a NOT LIKE() comparison expression with the given arguments.
258
+     *
259
+     * @param string $x Field in string format to be inspected by NOT LIKE() comparison.
260
+     * @param mixed $y Argument to be used in NOT LIKE() comparison.
261
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
262
+     *                  required when comparing text fields for oci compatibility
263
+     *
264
+     * @return string
265
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
266
+     */
267
+    public function notLike($x, $y, $type = null);
268 268
 
269
-	/**
270
-	 * Creates a ILIKE() comparison expression with the given arguments.
271
-	 *
272
-	 * @param string $x Field in string format to be inspected by ILIKE() comparison.
273
-	 * @param mixed $y Argument to be used in ILIKE() comparison.
274
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
275
-	 *                  required when comparing text fields for oci compatibility
276
-	 *
277
-	 * @return string
278
-	 * @since 9.0.0
279
-	 */
280
-	public function iLike($x, $y, $type = null);
269
+    /**
270
+     * Creates a ILIKE() comparison expression with the given arguments.
271
+     *
272
+     * @param string $x Field in string format to be inspected by ILIKE() comparison.
273
+     * @param mixed $y Argument to be used in ILIKE() comparison.
274
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
275
+     *                  required when comparing text fields for oci compatibility
276
+     *
277
+     * @return string
278
+     * @since 9.0.0
279
+     */
280
+    public function iLike($x, $y, $type = null);
281 281
 
282
-	/**
283
-	 * Creates a IN () comparison expression with the given arguments.
284
-	 *
285
-	 * @param string $x The field in string format to be inspected by IN() comparison.
286
-	 * @param string|array $y The placeholder or the array of values to be used by IN() comparison.
287
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
288
-	 *                  required when comparing text fields for oci compatibility
289
-	 *
290
-	 * @return string
291
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
292
-	 */
293
-	public function in($x, $y, $type = null);
282
+    /**
283
+     * Creates a IN () comparison expression with the given arguments.
284
+     *
285
+     * @param string $x The field in string format to be inspected by IN() comparison.
286
+     * @param string|array $y The placeholder or the array of values to be used by IN() comparison.
287
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
288
+     *                  required when comparing text fields for oci compatibility
289
+     *
290
+     * @return string
291
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
292
+     */
293
+    public function in($x, $y, $type = null);
294 294
 
295
-	/**
296
-	 * Creates a NOT IN () comparison expression with the given arguments.
297
-	 *
298
-	 * @param string $x The field in string format to be inspected by NOT IN() comparison.
299
-	 * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison.
300
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
301
-	 *                  required when comparing text fields for oci compatibility
302
-	 *
303
-	 * @return string
304
-	 * @since 8.2.0 - Parameter $type was added in 9.0.0
305
-	 */
306
-	public function notIn($x, $y, $type = null);
295
+    /**
296
+     * Creates a NOT IN () comparison expression with the given arguments.
297
+     *
298
+     * @param string $x The field in string format to be inspected by NOT IN() comparison.
299
+     * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison.
300
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
301
+     *                  required when comparing text fields for oci compatibility
302
+     *
303
+     * @return string
304
+     * @since 8.2.0 - Parameter $type was added in 9.0.0
305
+     */
306
+    public function notIn($x, $y, $type = null);
307 307
 
308
-	/**
309
-	 * Creates a $x = '' statement, because Oracle needs a different check
310
-	 *
311
-	 * @param string $x The field in string format to be inspected by the comparison.
312
-	 * @return string
313
-	 * @since 13.0.0
314
-	 */
315
-	public function emptyString($x);
308
+    /**
309
+     * Creates a $x = '' statement, because Oracle needs a different check
310
+     *
311
+     * @param string $x The field in string format to be inspected by the comparison.
312
+     * @return string
313
+     * @since 13.0.0
314
+     */
315
+    public function emptyString($x);
316 316
 
317
-	/**
318
-	 * Creates a `$x <> ''` statement, because Oracle needs a different check
319
-	 *
320
-	 * @param string $x The field in string format to be inspected by the comparison.
321
-	 * @return string
322
-	 * @since 13.0.0
323
-	 */
324
-	public function nonEmptyString($x);
317
+    /**
318
+     * Creates a `$x <> ''` statement, because Oracle needs a different check
319
+     *
320
+     * @param string $x The field in string format to be inspected by the comparison.
321
+     * @return string
322
+     * @since 13.0.0
323
+     */
324
+    public function nonEmptyString($x);
325 325
 
326 326
 
327
-	/**
328
-	 * Creates a bitwise AND comparison
329
-	 *
330
-	 * @param string|ILiteral $x The field or value to check
331
-	 * @param int $y Bitmap that must be set
332
-	 * @return IQueryFunction
333
-	 * @since 12.0.0
334
-	 */
335
-	public function bitwiseAnd($x, $y);
327
+    /**
328
+     * Creates a bitwise AND comparison
329
+     *
330
+     * @param string|ILiteral $x The field or value to check
331
+     * @param int $y Bitmap that must be set
332
+     * @return IQueryFunction
333
+     * @since 12.0.0
334
+     */
335
+    public function bitwiseAnd($x, $y);
336 336
 
337
-	/**
338
-	 * Creates a bitwise OR comparison
339
-	 *
340
-	 * @param string|ILiteral $x The field or value to check
341
-	 * @param int $y Bitmap that must be set
342
-	 * @return IQueryFunction
343
-	 * @since 12.0.0
344
-	 */
345
-	public function bitwiseOr($x, $y);
337
+    /**
338
+     * Creates a bitwise OR comparison
339
+     *
340
+     * @param string|ILiteral $x The field or value to check
341
+     * @param int $y Bitmap that must be set
342
+     * @return IQueryFunction
343
+     * @since 12.0.0
344
+     */
345
+    public function bitwiseOr($x, $y);
346 346
 
347
-	/**
348
-	 * Quotes a given input parameter.
349
-	 *
350
-	 * @param mixed $input The parameter to be quoted.
351
-	 * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants
352
-	 *
353
-	 * @return string
354
-	 * @since 8.2.0
355
-	 */
356
-	public function literal($input, $type = null);
347
+    /**
348
+     * Quotes a given input parameter.
349
+     *
350
+     * @param mixed $input The parameter to be quoted.
351
+     * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants
352
+     *
353
+     * @return string
354
+     * @since 8.2.0
355
+     */
356
+    public function literal($input, $type = null);
357 357
 
358
-	/**
359
-	 * Returns a IQueryFunction that casts the column to the given type
360
-	 *
361
-	 * @param string $column
362
-	 * @param mixed $type One of IQueryBuilder::PARAM_*
363
-	 * @return string
364
-	 * @since 9.0.0
365
-	 */
366
-	public function castColumn($column, $type);
358
+    /**
359
+     * Returns a IQueryFunction that casts the column to the given type
360
+     *
361
+     * @param string $column
362
+     * @param mixed $type One of IQueryBuilder::PARAM_*
363
+     * @return string
364
+     * @since 9.0.0
365
+     */
366
+    public function castColumn($column, $type);
367 367
 }
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php 1 patch
Indentation   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -37,396 +37,396 @@
 block discarded – undo
37 37
 use OCP\IDBConnection;
38 38
 
39 39
 class ExpressionBuilder implements IExpressionBuilder {
40
-	/** @var \Doctrine\DBAL\Query\Expression\ExpressionBuilder */
41
-	protected $expressionBuilder;
40
+    /** @var \Doctrine\DBAL\Query\Expression\ExpressionBuilder */
41
+    protected $expressionBuilder;
42 42
 
43
-	/** @var QuoteHelper */
44
-	protected $helper;
43
+    /** @var QuoteHelper */
44
+    protected $helper;
45 45
 
46
-	/** @var IDBConnection */
47
-	protected $connection;
46
+    /** @var IDBConnection */
47
+    protected $connection;
48 48
 
49
-	/** @var FunctionBuilder */
50
-	protected $functionBuilder;
49
+    /** @var FunctionBuilder */
50
+    protected $functionBuilder;
51 51
 
52
-	/**
53
-	 * Initializes a new <tt>ExpressionBuilder</tt>.
54
-	 *
55
-	 * @param IDBConnection $connection
56
-	 * @param IQueryBuilder $queryBuilder
57
-	 */
58
-	public function __construct(IDBConnection $connection, IQueryBuilder $queryBuilder) {
59
-		$this->connection = $connection;
60
-		$this->helper = new QuoteHelper();
61
-		$this->expressionBuilder = new DoctrineExpressionBuilder($connection);
62
-		$this->functionBuilder = $queryBuilder->func();
63
-	}
52
+    /**
53
+     * Initializes a new <tt>ExpressionBuilder</tt>.
54
+     *
55
+     * @param IDBConnection $connection
56
+     * @param IQueryBuilder $queryBuilder
57
+     */
58
+    public function __construct(IDBConnection $connection, IQueryBuilder $queryBuilder) {
59
+        $this->connection = $connection;
60
+        $this->helper = new QuoteHelper();
61
+        $this->expressionBuilder = new DoctrineExpressionBuilder($connection);
62
+        $this->functionBuilder = $queryBuilder->func();
63
+    }
64 64
 
65
-	/**
66
-	 * Creates a conjunction of the given boolean expressions.
67
-	 *
68
-	 * Example:
69
-	 *
70
-	 *     [php]
71
-	 *     // (u.type = ?) AND (u.role = ?)
72
-	 *     $expr->andX('u.type = ?', 'u.role = ?'));
73
-	 *
74
-	 * @param mixed ...$x Optional clause. Defaults = null, but requires
75
-	 *                 at least one defined when converting to string.
76
-	 *
77
-	 * @return \OCP\DB\QueryBuilder\ICompositeExpression
78
-	 */
79
-	public function andX(...$x) {
80
-		$compositeExpression = call_user_func_array([$this->expressionBuilder, 'andX'], $x);
81
-		return new CompositeExpression($compositeExpression);
82
-	}
65
+    /**
66
+     * Creates a conjunction of the given boolean expressions.
67
+     *
68
+     * Example:
69
+     *
70
+     *     [php]
71
+     *     // (u.type = ?) AND (u.role = ?)
72
+     *     $expr->andX('u.type = ?', 'u.role = ?'));
73
+     *
74
+     * @param mixed ...$x Optional clause. Defaults = null, but requires
75
+     *                 at least one defined when converting to string.
76
+     *
77
+     * @return \OCP\DB\QueryBuilder\ICompositeExpression
78
+     */
79
+    public function andX(...$x) {
80
+        $compositeExpression = call_user_func_array([$this->expressionBuilder, 'andX'], $x);
81
+        return new CompositeExpression($compositeExpression);
82
+    }
83 83
 
84
-	/**
85
-	 * Creates a disjunction of the given boolean expressions.
86
-	 *
87
-	 * Example:
88
-	 *
89
-	 *     [php]
90
-	 *     // (u.type = ?) OR (u.role = ?)
91
-	 *     $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?'));
92
-	 *
93
-	 * @param mixed ...$x Optional clause. Defaults = null, but requires
94
-	 *                 at least one defined when converting to string.
95
-	 *
96
-	 * @return \OCP\DB\QueryBuilder\ICompositeExpression
97
-	 */
98
-	public function orX(...$x) {
99
-		$compositeExpression = call_user_func_array([$this->expressionBuilder, 'orX'], $x);
100
-		return new CompositeExpression($compositeExpression);
101
-	}
84
+    /**
85
+     * Creates a disjunction of the given boolean expressions.
86
+     *
87
+     * Example:
88
+     *
89
+     *     [php]
90
+     *     // (u.type = ?) OR (u.role = ?)
91
+     *     $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?'));
92
+     *
93
+     * @param mixed ...$x Optional clause. Defaults = null, but requires
94
+     *                 at least one defined when converting to string.
95
+     *
96
+     * @return \OCP\DB\QueryBuilder\ICompositeExpression
97
+     */
98
+    public function orX(...$x) {
99
+        $compositeExpression = call_user_func_array([$this->expressionBuilder, 'orX'], $x);
100
+        return new CompositeExpression($compositeExpression);
101
+    }
102 102
 
103
-	/**
104
-	 * Creates a comparison expression.
105
-	 *
106
-	 * @param mixed $x The left expression.
107
-	 * @param string $operator One of the IExpressionBuilder::* constants.
108
-	 * @param mixed $y The right expression.
109
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
110
-	 *                  required when comparing text fields for oci compatibility
111
-	 *
112
-	 * @return string
113
-	 */
114
-	public function comparison($x, $operator, $y, $type = null) {
115
-		$x = $this->helper->quoteColumnName($x);
116
-		$y = $this->helper->quoteColumnName($y);
117
-		return $this->expressionBuilder->comparison($x, $operator, $y);
118
-	}
103
+    /**
104
+     * Creates a comparison expression.
105
+     *
106
+     * @param mixed $x The left expression.
107
+     * @param string $operator One of the IExpressionBuilder::* constants.
108
+     * @param mixed $y The right expression.
109
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
110
+     *                  required when comparing text fields for oci compatibility
111
+     *
112
+     * @return string
113
+     */
114
+    public function comparison($x, $operator, $y, $type = null) {
115
+        $x = $this->helper->quoteColumnName($x);
116
+        $y = $this->helper->quoteColumnName($y);
117
+        return $this->expressionBuilder->comparison($x, $operator, $y);
118
+    }
119 119
 
120
-	/**
121
-	 * Creates an equality comparison expression with the given arguments.
122
-	 *
123
-	 * First argument is considered the left expression and the second is the right expression.
124
-	 * When converted to string, it will generated a <left expr> = <right expr>. Example:
125
-	 *
126
-	 *     [php]
127
-	 *     // u.id = ?
128
-	 *     $expr->eq('u.id', '?');
129
-	 *
130
-	 * @param mixed $x The left expression.
131
-	 * @param mixed $y The right expression.
132
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
133
-	 *                  required when comparing text fields for oci compatibility
134
-	 *
135
-	 * @return string
136
-	 */
137
-	public function eq($x, $y, $type = null) {
138
-		$x = $this->helper->quoteColumnName($x);
139
-		$y = $this->helper->quoteColumnName($y);
140
-		return $this->expressionBuilder->eq($x, $y);
141
-	}
120
+    /**
121
+     * Creates an equality comparison expression with the given arguments.
122
+     *
123
+     * First argument is considered the left expression and the second is the right expression.
124
+     * When converted to string, it will generated a <left expr> = <right expr>. Example:
125
+     *
126
+     *     [php]
127
+     *     // u.id = ?
128
+     *     $expr->eq('u.id', '?');
129
+     *
130
+     * @param mixed $x The left expression.
131
+     * @param mixed $y The right expression.
132
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
133
+     *                  required when comparing text fields for oci compatibility
134
+     *
135
+     * @return string
136
+     */
137
+    public function eq($x, $y, $type = null) {
138
+        $x = $this->helper->quoteColumnName($x);
139
+        $y = $this->helper->quoteColumnName($y);
140
+        return $this->expressionBuilder->eq($x, $y);
141
+    }
142 142
 
143
-	/**
144
-	 * Creates a non equality comparison expression with the given arguments.
145
-	 * First argument is considered the left expression and the second is the right expression.
146
-	 * When converted to string, it will generated a <left expr> <> <right expr>. Example:
147
-	 *
148
-	 *     [php]
149
-	 *     // u.id <> 1
150
-	 *     $q->where($q->expr()->neq('u.id', '1'));
151
-	 *
152
-	 * @param mixed $x The left expression.
153
-	 * @param mixed $y The right expression.
154
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
155
-	 *                  required when comparing text fields for oci compatibility
156
-	 *
157
-	 * @return string
158
-	 */
159
-	public function neq($x, $y, $type = null) {
160
-		$x = $this->helper->quoteColumnName($x);
161
-		$y = $this->helper->quoteColumnName($y);
162
-		return $this->expressionBuilder->neq($x, $y);
163
-	}
143
+    /**
144
+     * Creates a non equality comparison expression with the given arguments.
145
+     * First argument is considered the left expression and the second is the right expression.
146
+     * When converted to string, it will generated a <left expr> <> <right expr>. Example:
147
+     *
148
+     *     [php]
149
+     *     // u.id <> 1
150
+     *     $q->where($q->expr()->neq('u.id', '1'));
151
+     *
152
+     * @param mixed $x The left expression.
153
+     * @param mixed $y The right expression.
154
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
155
+     *                  required when comparing text fields for oci compatibility
156
+     *
157
+     * @return string
158
+     */
159
+    public function neq($x, $y, $type = null) {
160
+        $x = $this->helper->quoteColumnName($x);
161
+        $y = $this->helper->quoteColumnName($y);
162
+        return $this->expressionBuilder->neq($x, $y);
163
+    }
164 164
 
165
-	/**
166
-	 * Creates a lower-than comparison expression with the given arguments.
167
-	 * First argument is considered the left expression and the second is the right expression.
168
-	 * When converted to string, it will generated a <left expr> < <right expr>. Example:
169
-	 *
170
-	 *     [php]
171
-	 *     // u.id < ?
172
-	 *     $q->where($q->expr()->lt('u.id', '?'));
173
-	 *
174
-	 * @param mixed $x The left expression.
175
-	 * @param mixed $y The right expression.
176
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
177
-	 *                  required when comparing text fields for oci compatibility
178
-	 *
179
-	 * @return string
180
-	 */
181
-	public function lt($x, $y, $type = null) {
182
-		$x = $this->helper->quoteColumnName($x);
183
-		$y = $this->helper->quoteColumnName($y);
184
-		return $this->expressionBuilder->lt($x, $y);
185
-	}
165
+    /**
166
+     * Creates a lower-than comparison expression with the given arguments.
167
+     * First argument is considered the left expression and the second is the right expression.
168
+     * When converted to string, it will generated a <left expr> < <right expr>. Example:
169
+     *
170
+     *     [php]
171
+     *     // u.id < ?
172
+     *     $q->where($q->expr()->lt('u.id', '?'));
173
+     *
174
+     * @param mixed $x The left expression.
175
+     * @param mixed $y The right expression.
176
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
177
+     *                  required when comparing text fields for oci compatibility
178
+     *
179
+     * @return string
180
+     */
181
+    public function lt($x, $y, $type = null) {
182
+        $x = $this->helper->quoteColumnName($x);
183
+        $y = $this->helper->quoteColumnName($y);
184
+        return $this->expressionBuilder->lt($x, $y);
185
+    }
186 186
 
187
-	/**
188
-	 * Creates a lower-than-equal comparison expression with the given arguments.
189
-	 * First argument is considered the left expression and the second is the right expression.
190
-	 * When converted to string, it will generated a <left expr> <= <right expr>. Example:
191
-	 *
192
-	 *     [php]
193
-	 *     // u.id <= ?
194
-	 *     $q->where($q->expr()->lte('u.id', '?'));
195
-	 *
196
-	 * @param mixed $x The left expression.
197
-	 * @param mixed $y The right expression.
198
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
199
-	 *                  required when comparing text fields for oci compatibility
200
-	 *
201
-	 * @return string
202
-	 */
203
-	public function lte($x, $y, $type = null) {
204
-		$x = $this->helper->quoteColumnName($x);
205
-		$y = $this->helper->quoteColumnName($y);
206
-		return $this->expressionBuilder->lte($x, $y);
207
-	}
187
+    /**
188
+     * Creates a lower-than-equal comparison expression with the given arguments.
189
+     * First argument is considered the left expression and the second is the right expression.
190
+     * When converted to string, it will generated a <left expr> <= <right expr>. Example:
191
+     *
192
+     *     [php]
193
+     *     // u.id <= ?
194
+     *     $q->where($q->expr()->lte('u.id', '?'));
195
+     *
196
+     * @param mixed $x The left expression.
197
+     * @param mixed $y The right expression.
198
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
199
+     *                  required when comparing text fields for oci compatibility
200
+     *
201
+     * @return string
202
+     */
203
+    public function lte($x, $y, $type = null) {
204
+        $x = $this->helper->quoteColumnName($x);
205
+        $y = $this->helper->quoteColumnName($y);
206
+        return $this->expressionBuilder->lte($x, $y);
207
+    }
208 208
 
209
-	/**
210
-	 * Creates a greater-than comparison expression with the given arguments.
211
-	 * First argument is considered the left expression and the second is the right expression.
212
-	 * When converted to string, it will generated a <left expr> > <right expr>. Example:
213
-	 *
214
-	 *     [php]
215
-	 *     // u.id > ?
216
-	 *     $q->where($q->expr()->gt('u.id', '?'));
217
-	 *
218
-	 * @param mixed $x The left expression.
219
-	 * @param mixed $y The right expression.
220
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
221
-	 *                  required when comparing text fields for oci compatibility
222
-	 *
223
-	 * @return string
224
-	 */
225
-	public function gt($x, $y, $type = null) {
226
-		$x = $this->helper->quoteColumnName($x);
227
-		$y = $this->helper->quoteColumnName($y);
228
-		return $this->expressionBuilder->gt($x, $y);
229
-	}
209
+    /**
210
+     * Creates a greater-than comparison expression with the given arguments.
211
+     * First argument is considered the left expression and the second is the right expression.
212
+     * When converted to string, it will generated a <left expr> > <right expr>. Example:
213
+     *
214
+     *     [php]
215
+     *     // u.id > ?
216
+     *     $q->where($q->expr()->gt('u.id', '?'));
217
+     *
218
+     * @param mixed $x The left expression.
219
+     * @param mixed $y The right expression.
220
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
221
+     *                  required when comparing text fields for oci compatibility
222
+     *
223
+     * @return string
224
+     */
225
+    public function gt($x, $y, $type = null) {
226
+        $x = $this->helper->quoteColumnName($x);
227
+        $y = $this->helper->quoteColumnName($y);
228
+        return $this->expressionBuilder->gt($x, $y);
229
+    }
230 230
 
231
-	/**
232
-	 * Creates a greater-than-equal comparison expression with the given arguments.
233
-	 * First argument is considered the left expression and the second is the right expression.
234
-	 * When converted to string, it will generated a <left expr> >= <right expr>. Example:
235
-	 *
236
-	 *     [php]
237
-	 *     // u.id >= ?
238
-	 *     $q->where($q->expr()->gte('u.id', '?'));
239
-	 *
240
-	 * @param mixed $x The left expression.
241
-	 * @param mixed $y The right expression.
242
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
243
-	 *                  required when comparing text fields for oci compatibility
244
-	 *
245
-	 * @return string
246
-	 */
247
-	public function gte($x, $y, $type = null) {
248
-		$x = $this->helper->quoteColumnName($x);
249
-		$y = $this->helper->quoteColumnName($y);
250
-		return $this->expressionBuilder->gte($x, $y);
251
-	}
231
+    /**
232
+     * Creates a greater-than-equal comparison expression with the given arguments.
233
+     * First argument is considered the left expression and the second is the right expression.
234
+     * When converted to string, it will generated a <left expr> >= <right expr>. Example:
235
+     *
236
+     *     [php]
237
+     *     // u.id >= ?
238
+     *     $q->where($q->expr()->gte('u.id', '?'));
239
+     *
240
+     * @param mixed $x The left expression.
241
+     * @param mixed $y The right expression.
242
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
243
+     *                  required when comparing text fields for oci compatibility
244
+     *
245
+     * @return string
246
+     */
247
+    public function gte($x, $y, $type = null) {
248
+        $x = $this->helper->quoteColumnName($x);
249
+        $y = $this->helper->quoteColumnName($y);
250
+        return $this->expressionBuilder->gte($x, $y);
251
+    }
252 252
 
253
-	/**
254
-	 * Creates an IS NULL expression with the given arguments.
255
-	 *
256
-	 * @param string $x The field in string format to be restricted by IS NULL.
257
-	 *
258
-	 * @return string
259
-	 */
260
-	public function isNull($x) {
261
-		$x = $this->helper->quoteColumnName($x);
262
-		return $this->expressionBuilder->isNull($x);
263
-	}
253
+    /**
254
+     * Creates an IS NULL expression with the given arguments.
255
+     *
256
+     * @param string $x The field in string format to be restricted by IS NULL.
257
+     *
258
+     * @return string
259
+     */
260
+    public function isNull($x) {
261
+        $x = $this->helper->quoteColumnName($x);
262
+        return $this->expressionBuilder->isNull($x);
263
+    }
264 264
 
265
-	/**
266
-	 * Creates an IS NOT NULL expression with the given arguments.
267
-	 *
268
-	 * @param string $x The field in string format to be restricted by IS NOT NULL.
269
-	 *
270
-	 * @return string
271
-	 */
272
-	public function isNotNull($x) {
273
-		$x = $this->helper->quoteColumnName($x);
274
-		return $this->expressionBuilder->isNotNull($x);
275
-	}
265
+    /**
266
+     * Creates an IS NOT NULL expression with the given arguments.
267
+     *
268
+     * @param string $x The field in string format to be restricted by IS NOT NULL.
269
+     *
270
+     * @return string
271
+     */
272
+    public function isNotNull($x) {
273
+        $x = $this->helper->quoteColumnName($x);
274
+        return $this->expressionBuilder->isNotNull($x);
275
+    }
276 276
 
277
-	/**
278
-	 * Creates a LIKE() comparison expression with the given arguments.
279
-	 *
280
-	 * @param string $x Field in string format to be inspected by LIKE() comparison.
281
-	 * @param mixed $y Argument to be used in LIKE() comparison.
282
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
283
-	 *                  required when comparing text fields for oci compatibility
284
-	 *
285
-	 * @return string
286
-	 */
287
-	public function like($x, $y, $type = null) {
288
-		$x = $this->helper->quoteColumnName($x);
289
-		$y = $this->helper->quoteColumnName($y);
290
-		return $this->expressionBuilder->like($x, $y);
291
-	}
277
+    /**
278
+     * Creates a LIKE() comparison expression with the given arguments.
279
+     *
280
+     * @param string $x Field in string format to be inspected by LIKE() comparison.
281
+     * @param mixed $y Argument to be used in LIKE() comparison.
282
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
283
+     *                  required when comparing text fields for oci compatibility
284
+     *
285
+     * @return string
286
+     */
287
+    public function like($x, $y, $type = null) {
288
+        $x = $this->helper->quoteColumnName($x);
289
+        $y = $this->helper->quoteColumnName($y);
290
+        return $this->expressionBuilder->like($x, $y);
291
+    }
292 292
 
293
-	/**
294
-	 * Creates a ILIKE() comparison expression with the given arguments.
295
-	 *
296
-	 * @param string $x Field in string format to be inspected by ILIKE() comparison.
297
-	 * @param mixed $y Argument to be used in ILIKE() comparison.
298
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
299
-	 *                  required when comparing text fields for oci compatibility
300
-	 *
301
-	 * @return string
302
-	 * @since 9.0.0
303
-	 */
304
-	public function iLike($x, $y, $type = null) {
305
-		return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y));
306
-	}
293
+    /**
294
+     * Creates a ILIKE() comparison expression with the given arguments.
295
+     *
296
+     * @param string $x Field in string format to be inspected by ILIKE() comparison.
297
+     * @param mixed $y Argument to be used in ILIKE() comparison.
298
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
299
+     *                  required when comparing text fields for oci compatibility
300
+     *
301
+     * @return string
302
+     * @since 9.0.0
303
+     */
304
+    public function iLike($x, $y, $type = null) {
305
+        return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y));
306
+    }
307 307
 
308
-	/**
309
-	 * Creates a NOT LIKE() comparison expression with the given arguments.
310
-	 *
311
-	 * @param string $x Field in string format to be inspected by NOT LIKE() comparison.
312
-	 * @param mixed $y Argument to be used in NOT LIKE() comparison.
313
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
314
-	 *                  required when comparing text fields for oci compatibility
315
-	 *
316
-	 * @return string
317
-	 */
318
-	public function notLike($x, $y, $type = null) {
319
-		$x = $this->helper->quoteColumnName($x);
320
-		$y = $this->helper->quoteColumnName($y);
321
-		return $this->expressionBuilder->notLike($x, $y);
322
-	}
308
+    /**
309
+     * Creates a NOT LIKE() comparison expression with the given arguments.
310
+     *
311
+     * @param string $x Field in string format to be inspected by NOT LIKE() comparison.
312
+     * @param mixed $y Argument to be used in NOT LIKE() comparison.
313
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
314
+     *                  required when comparing text fields for oci compatibility
315
+     *
316
+     * @return string
317
+     */
318
+    public function notLike($x, $y, $type = null) {
319
+        $x = $this->helper->quoteColumnName($x);
320
+        $y = $this->helper->quoteColumnName($y);
321
+        return $this->expressionBuilder->notLike($x, $y);
322
+    }
323 323
 
324
-	/**
325
-	 * Creates a IN () comparison expression with the given arguments.
326
-	 *
327
-	 * @param string $x The field in string format to be inspected by IN() comparison.
328
-	 * @param string|array $y The placeholder or the array of values to be used by IN() comparison.
329
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
330
-	 *                  required when comparing text fields for oci compatibility
331
-	 *
332
-	 * @return string
333
-	 */
334
-	public function in($x, $y, $type = null) {
335
-		$x = $this->helper->quoteColumnName($x);
336
-		$y = $this->helper->quoteColumnNames($y);
337
-		return $this->expressionBuilder->in($x, $y);
338
-	}
324
+    /**
325
+     * Creates a IN () comparison expression with the given arguments.
326
+     *
327
+     * @param string $x The field in string format to be inspected by IN() comparison.
328
+     * @param string|array $y The placeholder or the array of values to be used by IN() comparison.
329
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
330
+     *                  required when comparing text fields for oci compatibility
331
+     *
332
+     * @return string
333
+     */
334
+    public function in($x, $y, $type = null) {
335
+        $x = $this->helper->quoteColumnName($x);
336
+        $y = $this->helper->quoteColumnNames($y);
337
+        return $this->expressionBuilder->in($x, $y);
338
+    }
339 339
 
340
-	/**
341
-	 * Creates a NOT IN () comparison expression with the given arguments.
342
-	 *
343
-	 * @param string $x The field in string format to be inspected by NOT IN() comparison.
344
-	 * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison.
345
-	 * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
346
-	 *                  required when comparing text fields for oci compatibility
347
-	 *
348
-	 * @return string
349
-	 */
350
-	public function notIn($x, $y, $type = null) {
351
-		$x = $this->helper->quoteColumnName($x);
352
-		$y = $this->helper->quoteColumnNames($y);
353
-		return $this->expressionBuilder->notIn($x, $y);
354
-	}
340
+    /**
341
+     * Creates a NOT IN () comparison expression with the given arguments.
342
+     *
343
+     * @param string $x The field in string format to be inspected by NOT IN() comparison.
344
+     * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison.
345
+     * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
346
+     *                  required when comparing text fields for oci compatibility
347
+     *
348
+     * @return string
349
+     */
350
+    public function notIn($x, $y, $type = null) {
351
+        $x = $this->helper->quoteColumnName($x);
352
+        $y = $this->helper->quoteColumnNames($y);
353
+        return $this->expressionBuilder->notIn($x, $y);
354
+    }
355 355
 
356
-	/**
357
-	 * Creates a $x = '' statement, because Oracle needs a different check
358
-	 *
359
-	 * @param string $x The field in string format to be inspected by the comparison.
360
-	 * @return string
361
-	 * @since 13.0.0
362
-	 */
363
-	public function emptyString($x) {
364
-		return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR));
365
-	}
356
+    /**
357
+     * Creates a $x = '' statement, because Oracle needs a different check
358
+     *
359
+     * @param string $x The field in string format to be inspected by the comparison.
360
+     * @return string
361
+     * @since 13.0.0
362
+     */
363
+    public function emptyString($x) {
364
+        return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR));
365
+    }
366 366
 
367
-	/**
368
-	 * Creates a `$x <> ''` statement, because Oracle needs a different check
369
-	 *
370
-	 * @param string $x The field in string format to be inspected by the comparison.
371
-	 * @return string
372
-	 * @since 13.0.0
373
-	 */
374
-	public function nonEmptyString($x) {
375
-		return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR));
376
-	}
367
+    /**
368
+     * Creates a `$x <> ''` statement, because Oracle needs a different check
369
+     *
370
+     * @param string $x The field in string format to be inspected by the comparison.
371
+     * @return string
372
+     * @since 13.0.0
373
+     */
374
+    public function nonEmptyString($x) {
375
+        return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR));
376
+    }
377 377
 
378
-	/**
379
-	 * Binary AND Operator copies a bit to the result if it exists in both operands.
380
-	 *
381
-	 * @param string|ILiteral $x The field or value to check
382
-	 * @param int $y Bitmap that must be set
383
-	 * @return IQueryFunction
384
-	 * @since 12.0.0
385
-	 */
386
-	public function bitwiseAnd($x, $y) {
387
-		return new QueryFunction($this->connection->getDatabasePlatform()->getBitAndComparisonExpression(
388
-			$this->helper->quoteColumnName($x),
389
-			$y
390
-		));
391
-	}
378
+    /**
379
+     * Binary AND Operator copies a bit to the result if it exists in both operands.
380
+     *
381
+     * @param string|ILiteral $x The field or value to check
382
+     * @param int $y Bitmap that must be set
383
+     * @return IQueryFunction
384
+     * @since 12.0.0
385
+     */
386
+    public function bitwiseAnd($x, $y) {
387
+        return new QueryFunction($this->connection->getDatabasePlatform()->getBitAndComparisonExpression(
388
+            $this->helper->quoteColumnName($x),
389
+            $y
390
+        ));
391
+    }
392 392
 
393
-	/**
394
-	 * Binary OR Operator copies a bit if it exists in either operand.
395
-	 *
396
-	 * @param string|ILiteral $x The field or value to check
397
-	 * @param int $y Bitmap that must be set
398
-	 * @return IQueryFunction
399
-	 * @since 12.0.0
400
-	 */
401
-	public function bitwiseOr($x, $y) {
402
-		return new QueryFunction($this->connection->getDatabasePlatform()->getBitOrComparisonExpression(
403
-			$this->helper->quoteColumnName($x),
404
-			$y
405
-		));
406
-	}
393
+    /**
394
+     * Binary OR Operator copies a bit if it exists in either operand.
395
+     *
396
+     * @param string|ILiteral $x The field or value to check
397
+     * @param int $y Bitmap that must be set
398
+     * @return IQueryFunction
399
+     * @since 12.0.0
400
+     */
401
+    public function bitwiseOr($x, $y) {
402
+        return new QueryFunction($this->connection->getDatabasePlatform()->getBitOrComparisonExpression(
403
+            $this->helper->quoteColumnName($x),
404
+            $y
405
+        ));
406
+    }
407 407
 
408
-	/**
409
-	 * Quotes a given input parameter.
410
-	 *
411
-	 * @param mixed $input The parameter to be quoted.
412
-	 * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants
413
-	 *
414
-	 * @return ILiteral
415
-	 */
416
-	public function literal($input, $type = null) {
417
-		return new Literal($this->expressionBuilder->literal($input, $type));
418
-	}
408
+    /**
409
+     * Quotes a given input parameter.
410
+     *
411
+     * @param mixed $input The parameter to be quoted.
412
+     * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants
413
+     *
414
+     * @return ILiteral
415
+     */
416
+    public function literal($input, $type = null) {
417
+        return new Literal($this->expressionBuilder->literal($input, $type));
418
+    }
419 419
 
420
-	/**
421
-	 * Returns a IQueryFunction that casts the column to the given type
422
-	 *
423
-	 * @param string $column
424
-	 * @param mixed $type One of IQueryBuilder::PARAM_*
425
-	 * @return string
426
-	 */
427
-	public function castColumn($column, $type) {
428
-		return new QueryFunction(
429
-			$this->helper->quoteColumnName($column)
430
-		);
431
-	}
420
+    /**
421
+     * Returns a IQueryFunction that casts the column to the given type
422
+     *
423
+     * @param string $column
424
+     * @param mixed $type One of IQueryBuilder::PARAM_*
425
+     * @return string
426
+     */
427
+    public function castColumn($column, $type) {
428
+        return new QueryFunction(
429
+            $this->helper->quoteColumnName($column)
430
+        );
431
+    }
432 432
 }
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/QueryBuilder.php 1 patch
Indentation   +1169 added lines, -1169 removed lines patch added patch discarded remove patch
@@ -47,1173 +47,1173 @@
 block discarded – undo
47 47
 
48 48
 class QueryBuilder implements IQueryBuilder {
49 49
 
50
-	/** @var \OCP\IDBConnection */
51
-	private $connection;
52
-
53
-	/** @var SystemConfig */
54
-	private $systemConfig;
55
-
56
-	/** @var ILogger */
57
-	private $logger;
58
-
59
-	/** @var \Doctrine\DBAL\Query\QueryBuilder */
60
-	private $queryBuilder;
61
-
62
-	/** @var QuoteHelper */
63
-	private $helper;
64
-
65
-	/** @var bool */
66
-	private $automaticTablePrefix = true;
67
-
68
-	/** @var string */
69
-	protected $lastInsertedTable;
70
-
71
-	/**
72
-	 * Initializes a new QueryBuilder.
73
-	 *
74
-	 * @param IDBConnection $connection
75
-	 * @param SystemConfig $systemConfig
76
-	 * @param ILogger $logger
77
-	 */
78
-	public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) {
79
-		$this->connection = $connection;
80
-		$this->systemConfig = $systemConfig;
81
-		$this->logger = $logger;
82
-		$this->queryBuilder = new \Doctrine\DBAL\Query\QueryBuilder($this->connection);
83
-		$this->helper = new QuoteHelper();
84
-	}
85
-
86
-	/**
87
-	 * Enable/disable automatic prefixing of table names with the oc_ prefix
88
-	 *
89
-	 * @param bool $enabled If set to true table names will be prefixed with the
90
-	 * owncloud database prefix automatically.
91
-	 * @since 8.2.0
92
-	 */
93
-	public function automaticTablePrefix($enabled) {
94
-		$this->automaticTablePrefix = (bool) $enabled;
95
-	}
96
-
97
-	/**
98
-	 * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
99
-	 * This producer method is intended for convenient inline usage. Example:
100
-	 *
101
-	 * <code>
102
-	 *     $qb = $conn->getQueryBuilder()
103
-	 *         ->select('u')
104
-	 *         ->from('users', 'u')
105
-	 *         ->where($qb->expr()->eq('u.id', 1));
106
-	 * </code>
107
-	 *
108
-	 * For more complex expression construction, consider storing the expression
109
-	 * builder object in a local variable.
110
-	 *
111
-	 * @return \OCP\DB\QueryBuilder\IExpressionBuilder
112
-	 */
113
-	public function expr() {
114
-		if ($this->connection instanceof OracleConnection) {
115
-			return new OCIExpressionBuilder($this->connection, $this);
116
-		} else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
117
-			return new PgSqlExpressionBuilder($this->connection, $this);
118
-		} else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
119
-			return new MySqlExpressionBuilder($this->connection, $this);
120
-		} else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
121
-			return new SqliteExpressionBuilder($this->connection, $this);
122
-		} else {
123
-			return new ExpressionBuilder($this->connection, $this);
124
-		}
125
-	}
126
-
127
-	/**
128
-	 * Gets an FunctionBuilder used for object-oriented construction of query functions.
129
-	 * This producer method is intended for convenient inline usage. Example:
130
-	 *
131
-	 * <code>
132
-	 *     $qb = $conn->getQueryBuilder()
133
-	 *         ->select('u')
134
-	 *         ->from('users', 'u')
135
-	 *         ->where($qb->fun()->md5('u.id'));
136
-	 * </code>
137
-	 *
138
-	 * For more complex function construction, consider storing the function
139
-	 * builder object in a local variable.
140
-	 *
141
-	 * @return \OCP\DB\QueryBuilder\IFunctionBuilder
142
-	 */
143
-	public function func() {
144
-		if ($this->connection instanceof OracleConnection) {
145
-			return new OCIFunctionBuilder($this->helper);
146
-		} else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
147
-			return new SqliteFunctionBuilder($this->helper);
148
-		} else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
149
-			return new PgSqlFunctionBuilder($this->helper);
150
-		} else {
151
-			return new FunctionBuilder($this->helper);
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * Gets the type of the currently built query.
157
-	 *
158
-	 * @return integer
159
-	 */
160
-	public function getType() {
161
-		return $this->queryBuilder->getType();
162
-	}
163
-
164
-	/**
165
-	 * Gets the associated DBAL Connection for this query builder.
166
-	 *
167
-	 * @return \OCP\IDBConnection
168
-	 */
169
-	public function getConnection() {
170
-		return $this->connection;
171
-	}
172
-
173
-	/**
174
-	 * Gets the state of this query builder instance.
175
-	 *
176
-	 * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.
177
-	 */
178
-	public function getState() {
179
-		return $this->queryBuilder->getState();
180
-	}
181
-
182
-	/**
183
-	 * Executes this query using the bound parameters and their types.
184
-	 *
185
-	 * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
186
-	 * for insert, update and delete statements.
187
-	 *
188
-	 * @return \Doctrine\DBAL\Driver\Statement|int
189
-	 */
190
-	public function execute() {
191
-		if ($this->systemConfig->getValue('log_query', false)) {
192
-			$params = [];
193
-			foreach ($this->getParameters() as $placeholder => $value) {
194
-				if (is_array($value)) {
195
-					$params[] = $placeholder . ' => (\'' . implode('\', \'', $value) . '\')';
196
-				} else {
197
-					$params[] = $placeholder . ' => \'' . $value . '\'';
198
-				}
199
-			}
200
-			if (empty($params)) {
201
-				$this->logger->debug('DB QueryBuilder: \'{query}\'', [
202
-					'query' => $this->getSQL(),
203
-					'app' => 'core',
204
-				]);
205
-			} else {
206
-				$this->logger->debug('DB QueryBuilder: \'{query}\' with parameters: {params}', [
207
-					'query' => $this->getSQL(),
208
-					'params' => implode(', ', $params),
209
-					'app' => 'core',
210
-				]);
211
-			}
212
-		}
213
-
214
-		return $this->queryBuilder->execute();
215
-	}
216
-
217
-	/**
218
-	 * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
219
-	 *
220
-	 * <code>
221
-	 *     $qb = $conn->getQueryBuilder()
222
-	 *         ->select('u')
223
-	 *         ->from('User', 'u')
224
-	 *     echo $qb->getSQL(); // SELECT u FROM User u
225
-	 * </code>
226
-	 *
227
-	 * @return string The SQL query string.
228
-	 */
229
-	public function getSQL() {
230
-		return $this->queryBuilder->getSQL();
231
-	}
232
-
233
-	/**
234
-	 * Sets a query parameter for the query being constructed.
235
-	 *
236
-	 * <code>
237
-	 *     $qb = $conn->getQueryBuilder()
238
-	 *         ->select('u')
239
-	 *         ->from('users', 'u')
240
-	 *         ->where('u.id = :user_id')
241
-	 *         ->setParameter(':user_id', 1);
242
-	 * </code>
243
-	 *
244
-	 * @param string|integer $key The parameter position or name.
245
-	 * @param mixed $value The parameter value.
246
-	 * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
247
-	 *
248
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
249
-	 */
250
-	public function setParameter($key, $value, $type = null) {
251
-		$this->queryBuilder->setParameter($key, $value, $type);
252
-
253
-		return $this;
254
-	}
255
-
256
-	/**
257
-	 * Sets a collection of query parameters for the query being constructed.
258
-	 *
259
-	 * <code>
260
-	 *     $qb = $conn->getQueryBuilder()
261
-	 *         ->select('u')
262
-	 *         ->from('users', 'u')
263
-	 *         ->where('u.id = :user_id1 OR u.id = :user_id2')
264
-	 *         ->setParameters(array(
265
-	 *             ':user_id1' => 1,
266
-	 *             ':user_id2' => 2
267
-	 *         ));
268
-	 * </code>
269
-	 *
270
-	 * @param array $params The query parameters to set.
271
-	 * @param array $types The query parameters types to set.
272
-	 *
273
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
274
-	 */
275
-	public function setParameters(array $params, array $types = array()) {
276
-		$this->queryBuilder->setParameters($params, $types);
277
-
278
-		return $this;
279
-	}
280
-
281
-	/**
282
-	 * Gets all defined query parameters for the query being constructed indexed by parameter index or name.
283
-	 *
284
-	 * @return array The currently defined query parameters indexed by parameter index or name.
285
-	 */
286
-	public function getParameters() {
287
-		return $this->queryBuilder->getParameters();
288
-	}
289
-
290
-	/**
291
-	 * Gets a (previously set) query parameter of the query being constructed.
292
-	 *
293
-	 * @param mixed $key The key (index or name) of the bound parameter.
294
-	 *
295
-	 * @return mixed The value of the bound parameter.
296
-	 */
297
-	public function getParameter($key) {
298
-		return $this->queryBuilder->getParameter($key);
299
-	}
300
-
301
-	/**
302
-	 * Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
303
-	 *
304
-	 * @return array The currently defined query parameter types indexed by parameter index or name.
305
-	 */
306
-	public function getParameterTypes() {
307
-		return $this->queryBuilder->getParameterTypes();
308
-	}
309
-
310
-	/**
311
-	 * Gets a (previously set) query parameter type of the query being constructed.
312
-	 *
313
-	 * @param mixed $key The key (index or name) of the bound parameter type.
314
-	 *
315
-	 * @return mixed The value of the bound parameter type.
316
-	 */
317
-	public function getParameterType($key) {
318
-		return $this->queryBuilder->getParameterType($key);
319
-	}
320
-
321
-	/**
322
-	 * Sets the position of the first result to retrieve (the "offset").
323
-	 *
324
-	 * @param integer $firstResult The first result to return.
325
-	 *
326
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
327
-	 */
328
-	public function setFirstResult($firstResult) {
329
-		$this->queryBuilder->setFirstResult($firstResult);
330
-
331
-		return $this;
332
-	}
333
-
334
-	/**
335
-	 * Gets the position of the first result the query object was set to retrieve (the "offset").
336
-	 * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
337
-	 *
338
-	 * @return integer The position of the first result.
339
-	 */
340
-	public function getFirstResult() {
341
-		return $this->queryBuilder->getFirstResult();
342
-	}
343
-
344
-	/**
345
-	 * Sets the maximum number of results to retrieve (the "limit").
346
-	 *
347
-	 * NOTE: Setting max results to "0" will cause mixed behaviour. While most
348
-	 * of the databases will just return an empty result set, Oracle will return
349
-	 * all entries.
350
-	 *
351
-	 * @param integer $maxResults The maximum number of results to retrieve.
352
-	 *
353
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
354
-	 */
355
-	public function setMaxResults($maxResults) {
356
-		$this->queryBuilder->setMaxResults($maxResults);
357
-
358
-		return $this;
359
-	}
360
-
361
-	/**
362
-	 * Gets the maximum number of results the query object was set to retrieve (the "limit").
363
-	 * Returns NULL if {@link setMaxResults} was not applied to this query builder.
364
-	 *
365
-	 * @return integer The maximum number of results.
366
-	 */
367
-	public function getMaxResults() {
368
-		return $this->queryBuilder->getMaxResults();
369
-	}
370
-
371
-	/**
372
-	 * Specifies an item that is to be returned in the query result.
373
-	 * Replaces any previously specified selections, if any.
374
-	 *
375
-	 * <code>
376
-	 *     $qb = $conn->getQueryBuilder()
377
-	 *         ->select('u.id', 'p.id')
378
-	 *         ->from('users', 'u')
379
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
380
-	 * </code>
381
-	 *
382
-	 * @param mixed ...$selects The selection expressions.
383
-	 *
384
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
385
-	 */
386
-	public function select(...$selects) {
387
-		if (count($selects) === 1 && is_array($selects[0])) {
388
-			$selects = $selects[0];
389
-		}
390
-
391
-		$this->queryBuilder->select(
392
-			$this->helper->quoteColumnNames($selects)
393
-		);
394
-
395
-		return $this;
396
-	}
397
-
398
-	/**
399
-	 * Specifies an item that is to be returned with a different name in the query result.
400
-	 *
401
-	 * <code>
402
-	 *     $qb = $conn->getQueryBuilder()
403
-	 *         ->selectAlias('u.id', 'user_id')
404
-	 *         ->from('users', 'u')
405
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
406
-	 * </code>
407
-	 *
408
-	 * @param mixed $select The selection expressions.
409
-	 * @param string $alias The column alias used in the constructed query.
410
-	 *
411
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
412
-	 */
413
-	public function selectAlias($select, $alias) {
414
-
415
-		$this->queryBuilder->addSelect(
416
-			$this->helper->quoteColumnName($select) . ' AS ' . $this->helper->quoteColumnName($alias)
417
-		);
418
-
419
-		return $this;
420
-	}
421
-
422
-	/**
423
-	 * Specifies an item that is to be returned uniquely in the query result.
424
-	 *
425
-	 * <code>
426
-	 *     $qb = $conn->getQueryBuilder()
427
-	 *         ->selectDistinct('type')
428
-	 *         ->from('users');
429
-	 * </code>
430
-	 *
431
-	 * @param mixed $select The selection expressions.
432
-	 *
433
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
434
-	 */
435
-	public function selectDistinct($select) {
436
-
437
-		$this->queryBuilder->addSelect(
438
-			'DISTINCT ' . $this->helper->quoteColumnName($select)
439
-		);
440
-
441
-		return $this;
442
-	}
443
-
444
-	/**
445
-	 * Adds an item that is to be returned in the query result.
446
-	 *
447
-	 * <code>
448
-	 *     $qb = $conn->getQueryBuilder()
449
-	 *         ->select('u.id')
450
-	 *         ->addSelect('p.id')
451
-	 *         ->from('users', 'u')
452
-	 *         ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
453
-	 * </code>
454
-	 *
455
-	 * @param mixed ...$selects The selection expression.
456
-	 *
457
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
458
-	 */
459
-	public function addSelect(...$selects) {
460
-		if (count($selects) === 1 && is_array($selects[0])) {
461
-			$selects = $selects[0];
462
-		}
463
-
464
-		$this->queryBuilder->addSelect(
465
-			$this->helper->quoteColumnNames($selects)
466
-		);
467
-
468
-		return $this;
469
-	}
470
-
471
-	/**
472
-	 * Turns the query being built into a bulk delete query that ranges over
473
-	 * a certain table.
474
-	 *
475
-	 * <code>
476
-	 *     $qb = $conn->getQueryBuilder()
477
-	 *         ->delete('users', 'u')
478
-	 *         ->where('u.id = :user_id');
479
-	 *         ->setParameter(':user_id', 1);
480
-	 * </code>
481
-	 *
482
-	 * @param string $delete The table whose rows are subject to the deletion.
483
-	 * @param string $alias The table alias used in the constructed query.
484
-	 *
485
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
486
-	 */
487
-	public function delete($delete = null, $alias = null) {
488
-		$this->queryBuilder->delete(
489
-			$this->getTableName($delete),
490
-			$alias
491
-		);
492
-
493
-		return $this;
494
-	}
495
-
496
-	/**
497
-	 * Turns the query being built into a bulk update query that ranges over
498
-	 * a certain table
499
-	 *
500
-	 * <code>
501
-	 *     $qb = $conn->getQueryBuilder()
502
-	 *         ->update('users', 'u')
503
-	 *         ->set('u.password', md5('password'))
504
-	 *         ->where('u.id = ?');
505
-	 * </code>
506
-	 *
507
-	 * @param string $update The table whose rows are subject to the update.
508
-	 * @param string $alias The table alias used in the constructed query.
509
-	 *
510
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
511
-	 */
512
-	public function update($update = null, $alias = null) {
513
-		$this->queryBuilder->update(
514
-			$this->getTableName($update),
515
-			$alias
516
-		);
517
-
518
-		return $this;
519
-	}
520
-
521
-	/**
522
-	 * Turns the query being built into an insert query that inserts into
523
-	 * a certain table
524
-	 *
525
-	 * <code>
526
-	 *     $qb = $conn->getQueryBuilder()
527
-	 *         ->insert('users')
528
-	 *         ->values(
529
-	 *             array(
530
-	 *                 'name' => '?',
531
-	 *                 'password' => '?'
532
-	 *             )
533
-	 *         );
534
-	 * </code>
535
-	 *
536
-	 * @param string $insert The table into which the rows should be inserted.
537
-	 *
538
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
539
-	 */
540
-	public function insert($insert = null) {
541
-		$this->queryBuilder->insert(
542
-			$this->getTableName($insert)
543
-		);
544
-
545
-		$this->lastInsertedTable = $insert;
546
-
547
-		return $this;
548
-	}
549
-
550
-	/**
551
-	 * Creates and adds a query root corresponding to the table identified by the
552
-	 * given alias, forming a cartesian product with any existing query roots.
553
-	 *
554
-	 * <code>
555
-	 *     $qb = $conn->getQueryBuilder()
556
-	 *         ->select('u.id')
557
-	 *         ->from('users', 'u')
558
-	 * </code>
559
-	 *
560
-	 * @param string $from The table.
561
-	 * @param string|null $alias The alias of the table.
562
-	 *
563
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
564
-	 */
565
-	public function from($from, $alias = null) {
566
-		$this->queryBuilder->from(
567
-			$this->getTableName($from),
568
-			$this->quoteAlias($alias)
569
-		);
570
-
571
-		return $this;
572
-	}
573
-
574
-	/**
575
-	 * Creates and adds a join to the query.
576
-	 *
577
-	 * <code>
578
-	 *     $qb = $conn->getQueryBuilder()
579
-	 *         ->select('u.name')
580
-	 *         ->from('users', 'u')
581
-	 *         ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
582
-	 * </code>
583
-	 *
584
-	 * @param string $fromAlias The alias that points to a from clause.
585
-	 * @param string $join The table name to join.
586
-	 * @param string $alias The alias of the join table.
587
-	 * @param string $condition The condition for the join.
588
-	 *
589
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
590
-	 */
591
-	public function join($fromAlias, $join, $alias, $condition = null) {
592
-		$this->queryBuilder->join(
593
-			$this->quoteAlias($fromAlias),
594
-			$this->getTableName($join),
595
-			$this->quoteAlias($alias),
596
-			$condition
597
-		);
598
-
599
-		return $this;
600
-	}
601
-
602
-	/**
603
-	 * Creates and adds a join to the query.
604
-	 *
605
-	 * <code>
606
-	 *     $qb = $conn->getQueryBuilder()
607
-	 *         ->select('u.name')
608
-	 *         ->from('users', 'u')
609
-	 *         ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
610
-	 * </code>
611
-	 *
612
-	 * @param string $fromAlias The alias that points to a from clause.
613
-	 * @param string $join The table name to join.
614
-	 * @param string $alias The alias of the join table.
615
-	 * @param string $condition The condition for the join.
616
-	 *
617
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
618
-	 */
619
-	public function innerJoin($fromAlias, $join, $alias, $condition = null) {
620
-		$this->queryBuilder->innerJoin(
621
-			$this->quoteAlias($fromAlias),
622
-			$this->getTableName($join),
623
-			$this->quoteAlias($alias),
624
-			$condition
625
-		);
626
-
627
-		return $this;
628
-	}
629
-
630
-	/**
631
-	 * Creates and adds a left join to the query.
632
-	 *
633
-	 * <code>
634
-	 *     $qb = $conn->getQueryBuilder()
635
-	 *         ->select('u.name')
636
-	 *         ->from('users', 'u')
637
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
638
-	 * </code>
639
-	 *
640
-	 * @param string $fromAlias The alias that points to a from clause.
641
-	 * @param string $join The table name to join.
642
-	 * @param string $alias The alias of the join table.
643
-	 * @param string $condition The condition for the join.
644
-	 *
645
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
646
-	 */
647
-	public function leftJoin($fromAlias, $join, $alias, $condition = null) {
648
-		$this->queryBuilder->leftJoin(
649
-			$this->quoteAlias($fromAlias),
650
-			$this->getTableName($join),
651
-			$this->quoteAlias($alias),
652
-			$condition
653
-		);
654
-
655
-		return $this;
656
-	}
657
-
658
-	/**
659
-	 * Creates and adds a right join to the query.
660
-	 *
661
-	 * <code>
662
-	 *     $qb = $conn->getQueryBuilder()
663
-	 *         ->select('u.name')
664
-	 *         ->from('users', 'u')
665
-	 *         ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
666
-	 * </code>
667
-	 *
668
-	 * @param string $fromAlias The alias that points to a from clause.
669
-	 * @param string $join The table name to join.
670
-	 * @param string $alias The alias of the join table.
671
-	 * @param string $condition The condition for the join.
672
-	 *
673
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
674
-	 */
675
-	public function rightJoin($fromAlias, $join, $alias, $condition = null) {
676
-		$this->queryBuilder->rightJoin(
677
-			$this->quoteAlias($fromAlias),
678
-			$this->getTableName($join),
679
-			$this->quoteAlias($alias),
680
-			$condition
681
-		);
682
-
683
-		return $this;
684
-	}
685
-
686
-	/**
687
-	 * Sets a new value for a column in a bulk update query.
688
-	 *
689
-	 * <code>
690
-	 *     $qb = $conn->getQueryBuilder()
691
-	 *         ->update('users', 'u')
692
-	 *         ->set('u.password', md5('password'))
693
-	 *         ->where('u.id = ?');
694
-	 * </code>
695
-	 *
696
-	 * @param string $key The column to set.
697
-	 * @param string $value The value, expression, placeholder, etc.
698
-	 *
699
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
700
-	 */
701
-	public function set($key, $value) {
702
-		$this->queryBuilder->set(
703
-			$this->helper->quoteColumnName($key),
704
-			$this->helper->quoteColumnName($value)
705
-		);
706
-
707
-		return $this;
708
-	}
709
-
710
-	/**
711
-	 * Specifies one or more restrictions to the query result.
712
-	 * Replaces any previously specified restrictions, if any.
713
-	 *
714
-	 * <code>
715
-	 *     $qb = $conn->getQueryBuilder()
716
-	 *         ->select('u.name')
717
-	 *         ->from('users', 'u')
718
-	 *         ->where('u.id = ?');
719
-	 *
720
-	 *     // You can optionally programatically build and/or expressions
721
-	 *     $qb = $conn->getQueryBuilder();
722
-	 *
723
-	 *     $or = $qb->expr()->orx();
724
-	 *     $or->add($qb->expr()->eq('u.id', 1));
725
-	 *     $or->add($qb->expr()->eq('u.id', 2));
726
-	 *
727
-	 *     $qb->update('users', 'u')
728
-	 *         ->set('u.password', md5('password'))
729
-	 *         ->where($or);
730
-	 * </code>
731
-	 *
732
-	 * @param mixed ...$predicates The restriction predicates.
733
-	 *
734
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
735
-	 */
736
-	public function where(...$predicates) {
737
-		call_user_func_array(
738
-			[$this->queryBuilder, 'where'],
739
-			$predicates
740
-		);
741
-
742
-		return $this;
743
-	}
744
-
745
-	/**
746
-	 * Adds one or more restrictions to the query results, forming a logical
747
-	 * conjunction with any previously specified restrictions.
748
-	 *
749
-	 * <code>
750
-	 *     $qb = $conn->getQueryBuilder()
751
-	 *         ->select('u')
752
-	 *         ->from('users', 'u')
753
-	 *         ->where('u.username LIKE ?')
754
-	 *         ->andWhere('u.is_active = 1');
755
-	 * </code>
756
-	 *
757
-	 * @param mixed ...$where The query restrictions.
758
-	 *
759
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
760
-	 *
761
-	 * @see where()
762
-	 */
763
-	public function andWhere(...$where) {
764
-		call_user_func_array(
765
-			[$this->queryBuilder, 'andWhere'],
766
-			$where
767
-		);
768
-
769
-		return $this;
770
-	}
771
-
772
-	/**
773
-	 * Adds one or more restrictions to the query results, forming a logical
774
-	 * disjunction with any previously specified restrictions.
775
-	 *
776
-	 * <code>
777
-	 *     $qb = $conn->getQueryBuilder()
778
-	 *         ->select('u.name')
779
-	 *         ->from('users', 'u')
780
-	 *         ->where('u.id = 1')
781
-	 *         ->orWhere('u.id = 2');
782
-	 * </code>
783
-	 *
784
-	 * @param mixed ...$where The WHERE statement.
785
-	 *
786
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
787
-	 *
788
-	 * @see where()
789
-	 */
790
-	public function orWhere(...$where) {
791
-		call_user_func_array(
792
-			[$this->queryBuilder, 'orWhere'],
793
-			$where
794
-		);
795
-
796
-		return $this;
797
-	}
798
-
799
-	/**
800
-	 * Specifies a grouping over the results of the query.
801
-	 * Replaces any previously specified groupings, if any.
802
-	 *
803
-	 * <code>
804
-	 *     $qb = $conn->getQueryBuilder()
805
-	 *         ->select('u.name')
806
-	 *         ->from('users', 'u')
807
-	 *         ->groupBy('u.id');
808
-	 * </code>
809
-	 *
810
-	 * @param mixed ...$groupBys The grouping expression.
811
-	 *
812
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
813
-	 */
814
-	public function groupBy(...$groupBys) {
815
-		if (count($groupBys) === 1 && is_array($groupBys[0])) {
816
-			$$groupBys = $groupBys[0];
817
-		}
818
-
819
-		call_user_func_array(
820
-			[$this->queryBuilder, 'groupBy'],
821
-			$this->helper->quoteColumnNames($groupBys)
822
-		);
823
-
824
-		return $this;
825
-	}
826
-
827
-	/**
828
-	 * Adds a grouping expression to the query.
829
-	 *
830
-	 * <code>
831
-	 *     $qb = $conn->getQueryBuilder()
832
-	 *         ->select('u.name')
833
-	 *         ->from('users', 'u')
834
-	 *         ->groupBy('u.lastLogin');
835
-	 *         ->addGroupBy('u.createdAt')
836
-	 * </code>
837
-	 *
838
-	 * @param mixed ...$groupBy The grouping expression.
839
-	 *
840
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
841
-	 */
842
-	public function addGroupBy(...$groupBys) {
843
-		if (count($groupBys) === 1 && is_array($groupBys[0])) {
844
-			$$groupBys = $groupBys[0];
845
-		}
846
-
847
-		call_user_func_array(
848
-			[$this->queryBuilder, 'addGroupBy'],
849
-			$this->helper->quoteColumnNames($groupBys)
850
-		);
851
-
852
-		return $this;
853
-	}
854
-
855
-	/**
856
-	 * Sets a value for a column in an insert query.
857
-	 *
858
-	 * <code>
859
-	 *     $qb = $conn->getQueryBuilder()
860
-	 *         ->insert('users')
861
-	 *         ->values(
862
-	 *             array(
863
-	 *                 'name' => '?'
864
-	 *             )
865
-	 *         )
866
-	 *         ->setValue('password', '?');
867
-	 * </code>
868
-	 *
869
-	 * @param string $column The column into which the value should be inserted.
870
-	 * @param string $value The value that should be inserted into the column.
871
-	 *
872
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
873
-	 */
874
-	public function setValue($column, $value) {
875
-		$this->queryBuilder->setValue(
876
-			$this->helper->quoteColumnName($column),
877
-			$value
878
-		);
879
-
880
-		return $this;
881
-	}
882
-
883
-	/**
884
-	 * Specifies values for an insert query indexed by column names.
885
-	 * Replaces any previous values, if any.
886
-	 *
887
-	 * <code>
888
-	 *     $qb = $conn->getQueryBuilder()
889
-	 *         ->insert('users')
890
-	 *         ->values(
891
-	 *             array(
892
-	 *                 'name' => '?',
893
-	 *                 'password' => '?'
894
-	 *             )
895
-	 *         );
896
-	 * </code>
897
-	 *
898
-	 * @param array $values The values to specify for the insert query indexed by column names.
899
-	 *
900
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
901
-	 */
902
-	public function values(array $values) {
903
-		$quotedValues = [];
904
-		foreach ($values as $key => $value) {
905
-			$quotedValues[$this->helper->quoteColumnName($key)] = $value;
906
-		}
907
-
908
-		$this->queryBuilder->values($quotedValues);
909
-
910
-		return $this;
911
-	}
912
-
913
-	/**
914
-	 * Specifies a restriction over the groups of the query.
915
-	 * Replaces any previous having restrictions, if any.
916
-	 *
917
-	 * @param mixed ...$having The restriction over the groups.
918
-	 *
919
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
920
-	 */
921
-	public function having(...$having) {
922
-		call_user_func_array(
923
-			[$this->queryBuilder, 'having'],
924
-			$having
925
-		);
926
-
927
-		return $this;
928
-	}
929
-
930
-	/**
931
-	 * Adds a restriction over the groups of the query, forming a logical
932
-	 * conjunction with any existing having restrictions.
933
-	 *
934
-	 * @param mixed ...$having The restriction to append.
935
-	 *
936
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
937
-	 */
938
-	public function andHaving(...$having) {
939
-		call_user_func_array(
940
-			[$this->queryBuilder, 'andHaving'],
941
-			$having
942
-		);
943
-
944
-		return $this;
945
-	}
946
-
947
-	/**
948
-	 * Adds a restriction over the groups of the query, forming a logical
949
-	 * disjunction with any existing having restrictions.
950
-	 *
951
-	 * @param mixed ...$having The restriction to add.
952
-	 *
953
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
954
-	 */
955
-	public function orHaving(...$having) {
956
-		call_user_func_array(
957
-			[$this->queryBuilder, 'orHaving'],
958
-			$having
959
-		);
960
-
961
-		return $this;
962
-	}
963
-
964
-	/**
965
-	 * Specifies an ordering for the query results.
966
-	 * Replaces any previously specified orderings, if any.
967
-	 *
968
-	 * @param string $sort The ordering expression.
969
-	 * @param string $order The ordering direction.
970
-	 *
971
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
972
-	 */
973
-	public function orderBy($sort, $order = null) {
974
-		$this->queryBuilder->orderBy(
975
-			$this->helper->quoteColumnName($sort),
976
-			$order
977
-		);
978
-
979
-		return $this;
980
-	}
981
-
982
-	/**
983
-	 * Adds an ordering to the query results.
984
-	 *
985
-	 * @param string $sort The ordering expression.
986
-	 * @param string $order The ordering direction.
987
-	 *
988
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
989
-	 */
990
-	public function addOrderBy($sort, $order = null) {
991
-		$this->queryBuilder->addOrderBy(
992
-			$this->helper->quoteColumnName($sort),
993
-			$order
994
-		);
995
-
996
-		return $this;
997
-	}
998
-
999
-	/**
1000
-	 * Gets a query part by its name.
1001
-	 *
1002
-	 * @param string $queryPartName
1003
-	 *
1004
-	 * @return mixed
1005
-	 */
1006
-	public function getQueryPart($queryPartName) {
1007
-		return $this->queryBuilder->getQueryPart($queryPartName);
1008
-	}
1009
-
1010
-	/**
1011
-	 * Gets all query parts.
1012
-	 *
1013
-	 * @return array
1014
-	 */
1015
-	public function getQueryParts() {
1016
-		return $this->queryBuilder->getQueryParts();
1017
-	}
1018
-
1019
-	/**
1020
-	 * Resets SQL parts.
1021
-	 *
1022
-	 * @param array|null $queryPartNames
1023
-	 *
1024
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
1025
-	 */
1026
-	public function resetQueryParts($queryPartNames = null) {
1027
-		$this->queryBuilder->resetQueryParts($queryPartNames);
1028
-
1029
-		return $this;
1030
-	}
1031
-
1032
-	/**
1033
-	 * Resets a single SQL part.
1034
-	 *
1035
-	 * @param string $queryPartName
1036
-	 *
1037
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
1038
-	 */
1039
-	public function resetQueryPart($queryPartName) {
1040
-		$this->queryBuilder->resetQueryPart($queryPartName);
1041
-
1042
-		return $this;
1043
-	}
1044
-
1045
-	/**
1046
-	 * Creates a new named parameter and bind the value $value to it.
1047
-	 *
1048
-	 * This method provides a shortcut for PDOStatement::bindValue
1049
-	 * when using prepared statements.
1050
-	 *
1051
-	 * The parameter $value specifies the value that you want to bind. If
1052
-	 * $placeholder is not provided bindValue() will automatically create a
1053
-	 * placeholder for you. An automatic placeholder will be of the name
1054
-	 * ':dcValue1', ':dcValue2' etc.
1055
-	 *
1056
-	 * For more information see {@link http://php.net/pdostatement-bindparam}
1057
-	 *
1058
-	 * Example:
1059
-	 * <code>
1060
-	 * $value = 2;
1061
-	 * $q->eq( 'id', $q->bindValue( $value ) );
1062
-	 * $stmt = $q->executeQuery(); // executed with 'id = 2'
1063
-	 * </code>
1064
-	 *
1065
-	 * @license New BSD License
1066
-	 * @link http://www.zetacomponents.org
1067
-	 *
1068
-	 * @param mixed $value
1069
-	 * @param mixed $type
1070
-	 * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
1071
-	 *
1072
-	 * @return IParameter the placeholder name used.
1073
-	 */
1074
-	public function createNamedParameter($value, $type = IQueryBuilder::PARAM_STR, $placeHolder = null) {
1075
-		return new Parameter($this->queryBuilder->createNamedParameter($value, $type, $placeHolder));
1076
-	}
1077
-
1078
-	/**
1079
-	 * Creates a new positional parameter and bind the given value to it.
1080
-	 *
1081
-	 * Attention: If you are using positional parameters with the query builder you have
1082
-	 * to be very careful to bind all parameters in the order they appear in the SQL
1083
-	 * statement , otherwise they get bound in the wrong order which can lead to serious
1084
-	 * bugs in your code.
1085
-	 *
1086
-	 * Example:
1087
-	 * <code>
1088
-	 *  $qb = $conn->getQueryBuilder();
1089
-	 *  $qb->select('u.*')
1090
-	 *     ->from('users', 'u')
1091
-	 *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
1092
-	 *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
1093
-	 * </code>
1094
-	 *
1095
-	 * @param mixed $value
1096
-	 * @param integer $type
1097
-	 *
1098
-	 * @return IParameter
1099
-	 */
1100
-	public function createPositionalParameter($value, $type = IQueryBuilder::PARAM_STR) {
1101
-		return new Parameter($this->queryBuilder->createPositionalParameter($value, $type));
1102
-	}
1103
-
1104
-	/**
1105
-	 * Creates a new parameter
1106
-	 *
1107
-	 * Example:
1108
-	 * <code>
1109
-	 *  $qb = $conn->getQueryBuilder();
1110
-	 *  $qb->select('u.*')
1111
-	 *     ->from('users', 'u')
1112
-	 *     ->where('u.username = ' . $qb->createParameter('name'))
1113
-	 *     ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))
1114
-	 * </code>
1115
-	 *
1116
-	 * @param string $name
1117
-	 *
1118
-	 * @return IParameter
1119
-	 */
1120
-	public function createParameter($name) {
1121
-		return new Parameter(':' . $name);
1122
-	}
1123
-
1124
-	/**
1125
-	 * Creates a new function
1126
-	 *
1127
-	 * Attention: Column names inside the call have to be quoted before hand
1128
-	 *
1129
-	 * Example:
1130
-	 * <code>
1131
-	 *  $qb = $conn->getQueryBuilder();
1132
-	 *  $qb->select($qb->createFunction('COUNT(*)'))
1133
-	 *     ->from('users', 'u')
1134
-	 *  echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u
1135
-	 * </code>
1136
-	 * <code>
1137
-	 *  $qb = $conn->getQueryBuilder();
1138
-	 *  $qb->select($qb->createFunction('COUNT(`column`)'))
1139
-	 *     ->from('users', 'u')
1140
-	 *  echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u
1141
-	 * </code>
1142
-	 *
1143
-	 * @param string $call
1144
-	 *
1145
-	 * @return IQueryFunction
1146
-	 */
1147
-	public function createFunction($call) {
1148
-		return new QueryFunction($call);
1149
-	}
1150
-
1151
-	/**
1152
-	 * Used to get the id of the last inserted element
1153
-	 * @return int
1154
-	 * @throws \BadMethodCallException When being called before an insert query has been run.
1155
-	 */
1156
-	public function getLastInsertId() {
1157
-		if ($this->getType() === \Doctrine\DBAL\Query\QueryBuilder::INSERT && $this->lastInsertedTable) {
1158
-			// lastInsertId() needs the prefix but no quotes
1159
-			$table = $this->prefixTableName($this->lastInsertedTable);
1160
-			return (int) $this->connection->lastInsertId($table);
1161
-		}
1162
-
1163
-		throw new \BadMethodCallException('Invalid call to getLastInsertId without using insert() before.');
1164
-	}
1165
-
1166
-	/**
1167
-	 * Returns the table name quoted and with database prefix as needed by the implementation
1168
-	 *
1169
-	 * @param string $table
1170
-	 * @return string
1171
-	 */
1172
-	public function getTableName($table) {
1173
-		$table = $this->prefixTableName($table);
1174
-		return $this->helper->quoteColumnName($table);
1175
-	}
1176
-
1177
-	/**
1178
-	 * Returns the table name with database prefix as needed by the implementation
1179
-	 *
1180
-	 * @param string $table
1181
-	 * @return string
1182
-	 */
1183
-	protected function prefixTableName($table) {
1184
-		if ($this->automaticTablePrefix === false || strpos($table, '*PREFIX*') === 0) {
1185
-			return $table;
1186
-		}
1187
-
1188
-		return '*PREFIX*' . $table;
1189
-	}
1190
-
1191
-	/**
1192
-	 * Returns the column name quoted and with table alias prefix as needed by the implementation
1193
-	 *
1194
-	 * @param string $column
1195
-	 * @param string $tableAlias
1196
-	 * @return string
1197
-	 */
1198
-	public function getColumnName($column, $tableAlias = '') {
1199
-		if ($tableAlias !== '') {
1200
-			$tableAlias .= '.';
1201
-		}
1202
-
1203
-		return $this->helper->quoteColumnName($tableAlias . $column);
1204
-	}
1205
-
1206
-	/**
1207
-	 * Returns the column name quoted and with table alias prefix as needed by the implementation
1208
-	 *
1209
-	 * @param string $alias
1210
-	 * @return string
1211
-	 */
1212
-	public function quoteAlias($alias) {
1213
-		if ($alias === '' || $alias === null) {
1214
-			return $alias;
1215
-		}
1216
-
1217
-		return $this->helper->quoteColumnName($alias);
1218
-	}
50
+    /** @var \OCP\IDBConnection */
51
+    private $connection;
52
+
53
+    /** @var SystemConfig */
54
+    private $systemConfig;
55
+
56
+    /** @var ILogger */
57
+    private $logger;
58
+
59
+    /** @var \Doctrine\DBAL\Query\QueryBuilder */
60
+    private $queryBuilder;
61
+
62
+    /** @var QuoteHelper */
63
+    private $helper;
64
+
65
+    /** @var bool */
66
+    private $automaticTablePrefix = true;
67
+
68
+    /** @var string */
69
+    protected $lastInsertedTable;
70
+
71
+    /**
72
+     * Initializes a new QueryBuilder.
73
+     *
74
+     * @param IDBConnection $connection
75
+     * @param SystemConfig $systemConfig
76
+     * @param ILogger $logger
77
+     */
78
+    public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) {
79
+        $this->connection = $connection;
80
+        $this->systemConfig = $systemConfig;
81
+        $this->logger = $logger;
82
+        $this->queryBuilder = new \Doctrine\DBAL\Query\QueryBuilder($this->connection);
83
+        $this->helper = new QuoteHelper();
84
+    }
85
+
86
+    /**
87
+     * Enable/disable automatic prefixing of table names with the oc_ prefix
88
+     *
89
+     * @param bool $enabled If set to true table names will be prefixed with the
90
+     * owncloud database prefix automatically.
91
+     * @since 8.2.0
92
+     */
93
+    public function automaticTablePrefix($enabled) {
94
+        $this->automaticTablePrefix = (bool) $enabled;
95
+    }
96
+
97
+    /**
98
+     * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
99
+     * This producer method is intended for convenient inline usage. Example:
100
+     *
101
+     * <code>
102
+     *     $qb = $conn->getQueryBuilder()
103
+     *         ->select('u')
104
+     *         ->from('users', 'u')
105
+     *         ->where($qb->expr()->eq('u.id', 1));
106
+     * </code>
107
+     *
108
+     * For more complex expression construction, consider storing the expression
109
+     * builder object in a local variable.
110
+     *
111
+     * @return \OCP\DB\QueryBuilder\IExpressionBuilder
112
+     */
113
+    public function expr() {
114
+        if ($this->connection instanceof OracleConnection) {
115
+            return new OCIExpressionBuilder($this->connection, $this);
116
+        } else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
117
+            return new PgSqlExpressionBuilder($this->connection, $this);
118
+        } else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
119
+            return new MySqlExpressionBuilder($this->connection, $this);
120
+        } else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
121
+            return new SqliteExpressionBuilder($this->connection, $this);
122
+        } else {
123
+            return new ExpressionBuilder($this->connection, $this);
124
+        }
125
+    }
126
+
127
+    /**
128
+     * Gets an FunctionBuilder used for object-oriented construction of query functions.
129
+     * This producer method is intended for convenient inline usage. Example:
130
+     *
131
+     * <code>
132
+     *     $qb = $conn->getQueryBuilder()
133
+     *         ->select('u')
134
+     *         ->from('users', 'u')
135
+     *         ->where($qb->fun()->md5('u.id'));
136
+     * </code>
137
+     *
138
+     * For more complex function construction, consider storing the function
139
+     * builder object in a local variable.
140
+     *
141
+     * @return \OCP\DB\QueryBuilder\IFunctionBuilder
142
+     */
143
+    public function func() {
144
+        if ($this->connection instanceof OracleConnection) {
145
+            return new OCIFunctionBuilder($this->helper);
146
+        } else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
147
+            return new SqliteFunctionBuilder($this->helper);
148
+        } else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
149
+            return new PgSqlFunctionBuilder($this->helper);
150
+        } else {
151
+            return new FunctionBuilder($this->helper);
152
+        }
153
+    }
154
+
155
+    /**
156
+     * Gets the type of the currently built query.
157
+     *
158
+     * @return integer
159
+     */
160
+    public function getType() {
161
+        return $this->queryBuilder->getType();
162
+    }
163
+
164
+    /**
165
+     * Gets the associated DBAL Connection for this query builder.
166
+     *
167
+     * @return \OCP\IDBConnection
168
+     */
169
+    public function getConnection() {
170
+        return $this->connection;
171
+    }
172
+
173
+    /**
174
+     * Gets the state of this query builder instance.
175
+     *
176
+     * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.
177
+     */
178
+    public function getState() {
179
+        return $this->queryBuilder->getState();
180
+    }
181
+
182
+    /**
183
+     * Executes this query using the bound parameters and their types.
184
+     *
185
+     * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
186
+     * for insert, update and delete statements.
187
+     *
188
+     * @return \Doctrine\DBAL\Driver\Statement|int
189
+     */
190
+    public function execute() {
191
+        if ($this->systemConfig->getValue('log_query', false)) {
192
+            $params = [];
193
+            foreach ($this->getParameters() as $placeholder => $value) {
194
+                if (is_array($value)) {
195
+                    $params[] = $placeholder . ' => (\'' . implode('\', \'', $value) . '\')';
196
+                } else {
197
+                    $params[] = $placeholder . ' => \'' . $value . '\'';
198
+                }
199
+            }
200
+            if (empty($params)) {
201
+                $this->logger->debug('DB QueryBuilder: \'{query}\'', [
202
+                    'query' => $this->getSQL(),
203
+                    'app' => 'core',
204
+                ]);
205
+            } else {
206
+                $this->logger->debug('DB QueryBuilder: \'{query}\' with parameters: {params}', [
207
+                    'query' => $this->getSQL(),
208
+                    'params' => implode(', ', $params),
209
+                    'app' => 'core',
210
+                ]);
211
+            }
212
+        }
213
+
214
+        return $this->queryBuilder->execute();
215
+    }
216
+
217
+    /**
218
+     * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
219
+     *
220
+     * <code>
221
+     *     $qb = $conn->getQueryBuilder()
222
+     *         ->select('u')
223
+     *         ->from('User', 'u')
224
+     *     echo $qb->getSQL(); // SELECT u FROM User u
225
+     * </code>
226
+     *
227
+     * @return string The SQL query string.
228
+     */
229
+    public function getSQL() {
230
+        return $this->queryBuilder->getSQL();
231
+    }
232
+
233
+    /**
234
+     * Sets a query parameter for the query being constructed.
235
+     *
236
+     * <code>
237
+     *     $qb = $conn->getQueryBuilder()
238
+     *         ->select('u')
239
+     *         ->from('users', 'u')
240
+     *         ->where('u.id = :user_id')
241
+     *         ->setParameter(':user_id', 1);
242
+     * </code>
243
+     *
244
+     * @param string|integer $key The parameter position or name.
245
+     * @param mixed $value The parameter value.
246
+     * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
247
+     *
248
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
249
+     */
250
+    public function setParameter($key, $value, $type = null) {
251
+        $this->queryBuilder->setParameter($key, $value, $type);
252
+
253
+        return $this;
254
+    }
255
+
256
+    /**
257
+     * Sets a collection of query parameters for the query being constructed.
258
+     *
259
+     * <code>
260
+     *     $qb = $conn->getQueryBuilder()
261
+     *         ->select('u')
262
+     *         ->from('users', 'u')
263
+     *         ->where('u.id = :user_id1 OR u.id = :user_id2')
264
+     *         ->setParameters(array(
265
+     *             ':user_id1' => 1,
266
+     *             ':user_id2' => 2
267
+     *         ));
268
+     * </code>
269
+     *
270
+     * @param array $params The query parameters to set.
271
+     * @param array $types The query parameters types to set.
272
+     *
273
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
274
+     */
275
+    public function setParameters(array $params, array $types = array()) {
276
+        $this->queryBuilder->setParameters($params, $types);
277
+
278
+        return $this;
279
+    }
280
+
281
+    /**
282
+     * Gets all defined query parameters for the query being constructed indexed by parameter index or name.
283
+     *
284
+     * @return array The currently defined query parameters indexed by parameter index or name.
285
+     */
286
+    public function getParameters() {
287
+        return $this->queryBuilder->getParameters();
288
+    }
289
+
290
+    /**
291
+     * Gets a (previously set) query parameter of the query being constructed.
292
+     *
293
+     * @param mixed $key The key (index or name) of the bound parameter.
294
+     *
295
+     * @return mixed The value of the bound parameter.
296
+     */
297
+    public function getParameter($key) {
298
+        return $this->queryBuilder->getParameter($key);
299
+    }
300
+
301
+    /**
302
+     * Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
303
+     *
304
+     * @return array The currently defined query parameter types indexed by parameter index or name.
305
+     */
306
+    public function getParameterTypes() {
307
+        return $this->queryBuilder->getParameterTypes();
308
+    }
309
+
310
+    /**
311
+     * Gets a (previously set) query parameter type of the query being constructed.
312
+     *
313
+     * @param mixed $key The key (index or name) of the bound parameter type.
314
+     *
315
+     * @return mixed The value of the bound parameter type.
316
+     */
317
+    public function getParameterType($key) {
318
+        return $this->queryBuilder->getParameterType($key);
319
+    }
320
+
321
+    /**
322
+     * Sets the position of the first result to retrieve (the "offset").
323
+     *
324
+     * @param integer $firstResult The first result to return.
325
+     *
326
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
327
+     */
328
+    public function setFirstResult($firstResult) {
329
+        $this->queryBuilder->setFirstResult($firstResult);
330
+
331
+        return $this;
332
+    }
333
+
334
+    /**
335
+     * Gets the position of the first result the query object was set to retrieve (the "offset").
336
+     * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
337
+     *
338
+     * @return integer The position of the first result.
339
+     */
340
+    public function getFirstResult() {
341
+        return $this->queryBuilder->getFirstResult();
342
+    }
343
+
344
+    /**
345
+     * Sets the maximum number of results to retrieve (the "limit").
346
+     *
347
+     * NOTE: Setting max results to "0" will cause mixed behaviour. While most
348
+     * of the databases will just return an empty result set, Oracle will return
349
+     * all entries.
350
+     *
351
+     * @param integer $maxResults The maximum number of results to retrieve.
352
+     *
353
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
354
+     */
355
+    public function setMaxResults($maxResults) {
356
+        $this->queryBuilder->setMaxResults($maxResults);
357
+
358
+        return $this;
359
+    }
360
+
361
+    /**
362
+     * Gets the maximum number of results the query object was set to retrieve (the "limit").
363
+     * Returns NULL if {@link setMaxResults} was not applied to this query builder.
364
+     *
365
+     * @return integer The maximum number of results.
366
+     */
367
+    public function getMaxResults() {
368
+        return $this->queryBuilder->getMaxResults();
369
+    }
370
+
371
+    /**
372
+     * Specifies an item that is to be returned in the query result.
373
+     * Replaces any previously specified selections, if any.
374
+     *
375
+     * <code>
376
+     *     $qb = $conn->getQueryBuilder()
377
+     *         ->select('u.id', 'p.id')
378
+     *         ->from('users', 'u')
379
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
380
+     * </code>
381
+     *
382
+     * @param mixed ...$selects The selection expressions.
383
+     *
384
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
385
+     */
386
+    public function select(...$selects) {
387
+        if (count($selects) === 1 && is_array($selects[0])) {
388
+            $selects = $selects[0];
389
+        }
390
+
391
+        $this->queryBuilder->select(
392
+            $this->helper->quoteColumnNames($selects)
393
+        );
394
+
395
+        return $this;
396
+    }
397
+
398
+    /**
399
+     * Specifies an item that is to be returned with a different name in the query result.
400
+     *
401
+     * <code>
402
+     *     $qb = $conn->getQueryBuilder()
403
+     *         ->selectAlias('u.id', 'user_id')
404
+     *         ->from('users', 'u')
405
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
406
+     * </code>
407
+     *
408
+     * @param mixed $select The selection expressions.
409
+     * @param string $alias The column alias used in the constructed query.
410
+     *
411
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
412
+     */
413
+    public function selectAlias($select, $alias) {
414
+
415
+        $this->queryBuilder->addSelect(
416
+            $this->helper->quoteColumnName($select) . ' AS ' . $this->helper->quoteColumnName($alias)
417
+        );
418
+
419
+        return $this;
420
+    }
421
+
422
+    /**
423
+     * Specifies an item that is to be returned uniquely in the query result.
424
+     *
425
+     * <code>
426
+     *     $qb = $conn->getQueryBuilder()
427
+     *         ->selectDistinct('type')
428
+     *         ->from('users');
429
+     * </code>
430
+     *
431
+     * @param mixed $select The selection expressions.
432
+     *
433
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
434
+     */
435
+    public function selectDistinct($select) {
436
+
437
+        $this->queryBuilder->addSelect(
438
+            'DISTINCT ' . $this->helper->quoteColumnName($select)
439
+        );
440
+
441
+        return $this;
442
+    }
443
+
444
+    /**
445
+     * Adds an item that is to be returned in the query result.
446
+     *
447
+     * <code>
448
+     *     $qb = $conn->getQueryBuilder()
449
+     *         ->select('u.id')
450
+     *         ->addSelect('p.id')
451
+     *         ->from('users', 'u')
452
+     *         ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
453
+     * </code>
454
+     *
455
+     * @param mixed ...$selects The selection expression.
456
+     *
457
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
458
+     */
459
+    public function addSelect(...$selects) {
460
+        if (count($selects) === 1 && is_array($selects[0])) {
461
+            $selects = $selects[0];
462
+        }
463
+
464
+        $this->queryBuilder->addSelect(
465
+            $this->helper->quoteColumnNames($selects)
466
+        );
467
+
468
+        return $this;
469
+    }
470
+
471
+    /**
472
+     * Turns the query being built into a bulk delete query that ranges over
473
+     * a certain table.
474
+     *
475
+     * <code>
476
+     *     $qb = $conn->getQueryBuilder()
477
+     *         ->delete('users', 'u')
478
+     *         ->where('u.id = :user_id');
479
+     *         ->setParameter(':user_id', 1);
480
+     * </code>
481
+     *
482
+     * @param string $delete The table whose rows are subject to the deletion.
483
+     * @param string $alias The table alias used in the constructed query.
484
+     *
485
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
486
+     */
487
+    public function delete($delete = null, $alias = null) {
488
+        $this->queryBuilder->delete(
489
+            $this->getTableName($delete),
490
+            $alias
491
+        );
492
+
493
+        return $this;
494
+    }
495
+
496
+    /**
497
+     * Turns the query being built into a bulk update query that ranges over
498
+     * a certain table
499
+     *
500
+     * <code>
501
+     *     $qb = $conn->getQueryBuilder()
502
+     *         ->update('users', 'u')
503
+     *         ->set('u.password', md5('password'))
504
+     *         ->where('u.id = ?');
505
+     * </code>
506
+     *
507
+     * @param string $update The table whose rows are subject to the update.
508
+     * @param string $alias The table alias used in the constructed query.
509
+     *
510
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
511
+     */
512
+    public function update($update = null, $alias = null) {
513
+        $this->queryBuilder->update(
514
+            $this->getTableName($update),
515
+            $alias
516
+        );
517
+
518
+        return $this;
519
+    }
520
+
521
+    /**
522
+     * Turns the query being built into an insert query that inserts into
523
+     * a certain table
524
+     *
525
+     * <code>
526
+     *     $qb = $conn->getQueryBuilder()
527
+     *         ->insert('users')
528
+     *         ->values(
529
+     *             array(
530
+     *                 'name' => '?',
531
+     *                 'password' => '?'
532
+     *             )
533
+     *         );
534
+     * </code>
535
+     *
536
+     * @param string $insert The table into which the rows should be inserted.
537
+     *
538
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
539
+     */
540
+    public function insert($insert = null) {
541
+        $this->queryBuilder->insert(
542
+            $this->getTableName($insert)
543
+        );
544
+
545
+        $this->lastInsertedTable = $insert;
546
+
547
+        return $this;
548
+    }
549
+
550
+    /**
551
+     * Creates and adds a query root corresponding to the table identified by the
552
+     * given alias, forming a cartesian product with any existing query roots.
553
+     *
554
+     * <code>
555
+     *     $qb = $conn->getQueryBuilder()
556
+     *         ->select('u.id')
557
+     *         ->from('users', 'u')
558
+     * </code>
559
+     *
560
+     * @param string $from The table.
561
+     * @param string|null $alias The alias of the table.
562
+     *
563
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
564
+     */
565
+    public function from($from, $alias = null) {
566
+        $this->queryBuilder->from(
567
+            $this->getTableName($from),
568
+            $this->quoteAlias($alias)
569
+        );
570
+
571
+        return $this;
572
+    }
573
+
574
+    /**
575
+     * Creates and adds a join to the query.
576
+     *
577
+     * <code>
578
+     *     $qb = $conn->getQueryBuilder()
579
+     *         ->select('u.name')
580
+     *         ->from('users', 'u')
581
+     *         ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
582
+     * </code>
583
+     *
584
+     * @param string $fromAlias The alias that points to a from clause.
585
+     * @param string $join The table name to join.
586
+     * @param string $alias The alias of the join table.
587
+     * @param string $condition The condition for the join.
588
+     *
589
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
590
+     */
591
+    public function join($fromAlias, $join, $alias, $condition = null) {
592
+        $this->queryBuilder->join(
593
+            $this->quoteAlias($fromAlias),
594
+            $this->getTableName($join),
595
+            $this->quoteAlias($alias),
596
+            $condition
597
+        );
598
+
599
+        return $this;
600
+    }
601
+
602
+    /**
603
+     * Creates and adds a join to the query.
604
+     *
605
+     * <code>
606
+     *     $qb = $conn->getQueryBuilder()
607
+     *         ->select('u.name')
608
+     *         ->from('users', 'u')
609
+     *         ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
610
+     * </code>
611
+     *
612
+     * @param string $fromAlias The alias that points to a from clause.
613
+     * @param string $join The table name to join.
614
+     * @param string $alias The alias of the join table.
615
+     * @param string $condition The condition for the join.
616
+     *
617
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
618
+     */
619
+    public function innerJoin($fromAlias, $join, $alias, $condition = null) {
620
+        $this->queryBuilder->innerJoin(
621
+            $this->quoteAlias($fromAlias),
622
+            $this->getTableName($join),
623
+            $this->quoteAlias($alias),
624
+            $condition
625
+        );
626
+
627
+        return $this;
628
+    }
629
+
630
+    /**
631
+     * Creates and adds a left join to the query.
632
+     *
633
+     * <code>
634
+     *     $qb = $conn->getQueryBuilder()
635
+     *         ->select('u.name')
636
+     *         ->from('users', 'u')
637
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
638
+     * </code>
639
+     *
640
+     * @param string $fromAlias The alias that points to a from clause.
641
+     * @param string $join The table name to join.
642
+     * @param string $alias The alias of the join table.
643
+     * @param string $condition The condition for the join.
644
+     *
645
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
646
+     */
647
+    public function leftJoin($fromAlias, $join, $alias, $condition = null) {
648
+        $this->queryBuilder->leftJoin(
649
+            $this->quoteAlias($fromAlias),
650
+            $this->getTableName($join),
651
+            $this->quoteAlias($alias),
652
+            $condition
653
+        );
654
+
655
+        return $this;
656
+    }
657
+
658
+    /**
659
+     * Creates and adds a right join to the query.
660
+     *
661
+     * <code>
662
+     *     $qb = $conn->getQueryBuilder()
663
+     *         ->select('u.name')
664
+     *         ->from('users', 'u')
665
+     *         ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
666
+     * </code>
667
+     *
668
+     * @param string $fromAlias The alias that points to a from clause.
669
+     * @param string $join The table name to join.
670
+     * @param string $alias The alias of the join table.
671
+     * @param string $condition The condition for the join.
672
+     *
673
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
674
+     */
675
+    public function rightJoin($fromAlias, $join, $alias, $condition = null) {
676
+        $this->queryBuilder->rightJoin(
677
+            $this->quoteAlias($fromAlias),
678
+            $this->getTableName($join),
679
+            $this->quoteAlias($alias),
680
+            $condition
681
+        );
682
+
683
+        return $this;
684
+    }
685
+
686
+    /**
687
+     * Sets a new value for a column in a bulk update query.
688
+     *
689
+     * <code>
690
+     *     $qb = $conn->getQueryBuilder()
691
+     *         ->update('users', 'u')
692
+     *         ->set('u.password', md5('password'))
693
+     *         ->where('u.id = ?');
694
+     * </code>
695
+     *
696
+     * @param string $key The column to set.
697
+     * @param string $value The value, expression, placeholder, etc.
698
+     *
699
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
700
+     */
701
+    public function set($key, $value) {
702
+        $this->queryBuilder->set(
703
+            $this->helper->quoteColumnName($key),
704
+            $this->helper->quoteColumnName($value)
705
+        );
706
+
707
+        return $this;
708
+    }
709
+
710
+    /**
711
+     * Specifies one or more restrictions to the query result.
712
+     * Replaces any previously specified restrictions, if any.
713
+     *
714
+     * <code>
715
+     *     $qb = $conn->getQueryBuilder()
716
+     *         ->select('u.name')
717
+     *         ->from('users', 'u')
718
+     *         ->where('u.id = ?');
719
+     *
720
+     *     // You can optionally programatically build and/or expressions
721
+     *     $qb = $conn->getQueryBuilder();
722
+     *
723
+     *     $or = $qb->expr()->orx();
724
+     *     $or->add($qb->expr()->eq('u.id', 1));
725
+     *     $or->add($qb->expr()->eq('u.id', 2));
726
+     *
727
+     *     $qb->update('users', 'u')
728
+     *         ->set('u.password', md5('password'))
729
+     *         ->where($or);
730
+     * </code>
731
+     *
732
+     * @param mixed ...$predicates The restriction predicates.
733
+     *
734
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
735
+     */
736
+    public function where(...$predicates) {
737
+        call_user_func_array(
738
+            [$this->queryBuilder, 'where'],
739
+            $predicates
740
+        );
741
+
742
+        return $this;
743
+    }
744
+
745
+    /**
746
+     * Adds one or more restrictions to the query results, forming a logical
747
+     * conjunction with any previously specified restrictions.
748
+     *
749
+     * <code>
750
+     *     $qb = $conn->getQueryBuilder()
751
+     *         ->select('u')
752
+     *         ->from('users', 'u')
753
+     *         ->where('u.username LIKE ?')
754
+     *         ->andWhere('u.is_active = 1');
755
+     * </code>
756
+     *
757
+     * @param mixed ...$where The query restrictions.
758
+     *
759
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
760
+     *
761
+     * @see where()
762
+     */
763
+    public function andWhere(...$where) {
764
+        call_user_func_array(
765
+            [$this->queryBuilder, 'andWhere'],
766
+            $where
767
+        );
768
+
769
+        return $this;
770
+    }
771
+
772
+    /**
773
+     * Adds one or more restrictions to the query results, forming a logical
774
+     * disjunction with any previously specified restrictions.
775
+     *
776
+     * <code>
777
+     *     $qb = $conn->getQueryBuilder()
778
+     *         ->select('u.name')
779
+     *         ->from('users', 'u')
780
+     *         ->where('u.id = 1')
781
+     *         ->orWhere('u.id = 2');
782
+     * </code>
783
+     *
784
+     * @param mixed ...$where The WHERE statement.
785
+     *
786
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
787
+     *
788
+     * @see where()
789
+     */
790
+    public function orWhere(...$where) {
791
+        call_user_func_array(
792
+            [$this->queryBuilder, 'orWhere'],
793
+            $where
794
+        );
795
+
796
+        return $this;
797
+    }
798
+
799
+    /**
800
+     * Specifies a grouping over the results of the query.
801
+     * Replaces any previously specified groupings, if any.
802
+     *
803
+     * <code>
804
+     *     $qb = $conn->getQueryBuilder()
805
+     *         ->select('u.name')
806
+     *         ->from('users', 'u')
807
+     *         ->groupBy('u.id');
808
+     * </code>
809
+     *
810
+     * @param mixed ...$groupBys The grouping expression.
811
+     *
812
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
813
+     */
814
+    public function groupBy(...$groupBys) {
815
+        if (count($groupBys) === 1 && is_array($groupBys[0])) {
816
+            $$groupBys = $groupBys[0];
817
+        }
818
+
819
+        call_user_func_array(
820
+            [$this->queryBuilder, 'groupBy'],
821
+            $this->helper->quoteColumnNames($groupBys)
822
+        );
823
+
824
+        return $this;
825
+    }
826
+
827
+    /**
828
+     * Adds a grouping expression to the query.
829
+     *
830
+     * <code>
831
+     *     $qb = $conn->getQueryBuilder()
832
+     *         ->select('u.name')
833
+     *         ->from('users', 'u')
834
+     *         ->groupBy('u.lastLogin');
835
+     *         ->addGroupBy('u.createdAt')
836
+     * </code>
837
+     *
838
+     * @param mixed ...$groupBy The grouping expression.
839
+     *
840
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
841
+     */
842
+    public function addGroupBy(...$groupBys) {
843
+        if (count($groupBys) === 1 && is_array($groupBys[0])) {
844
+            $$groupBys = $groupBys[0];
845
+        }
846
+
847
+        call_user_func_array(
848
+            [$this->queryBuilder, 'addGroupBy'],
849
+            $this->helper->quoteColumnNames($groupBys)
850
+        );
851
+
852
+        return $this;
853
+    }
854
+
855
+    /**
856
+     * Sets a value for a column in an insert query.
857
+     *
858
+     * <code>
859
+     *     $qb = $conn->getQueryBuilder()
860
+     *         ->insert('users')
861
+     *         ->values(
862
+     *             array(
863
+     *                 'name' => '?'
864
+     *             )
865
+     *         )
866
+     *         ->setValue('password', '?');
867
+     * </code>
868
+     *
869
+     * @param string $column The column into which the value should be inserted.
870
+     * @param string $value The value that should be inserted into the column.
871
+     *
872
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
873
+     */
874
+    public function setValue($column, $value) {
875
+        $this->queryBuilder->setValue(
876
+            $this->helper->quoteColumnName($column),
877
+            $value
878
+        );
879
+
880
+        return $this;
881
+    }
882
+
883
+    /**
884
+     * Specifies values for an insert query indexed by column names.
885
+     * Replaces any previous values, if any.
886
+     *
887
+     * <code>
888
+     *     $qb = $conn->getQueryBuilder()
889
+     *         ->insert('users')
890
+     *         ->values(
891
+     *             array(
892
+     *                 'name' => '?',
893
+     *                 'password' => '?'
894
+     *             )
895
+     *         );
896
+     * </code>
897
+     *
898
+     * @param array $values The values to specify for the insert query indexed by column names.
899
+     *
900
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
901
+     */
902
+    public function values(array $values) {
903
+        $quotedValues = [];
904
+        foreach ($values as $key => $value) {
905
+            $quotedValues[$this->helper->quoteColumnName($key)] = $value;
906
+        }
907
+
908
+        $this->queryBuilder->values($quotedValues);
909
+
910
+        return $this;
911
+    }
912
+
913
+    /**
914
+     * Specifies a restriction over the groups of the query.
915
+     * Replaces any previous having restrictions, if any.
916
+     *
917
+     * @param mixed ...$having The restriction over the groups.
918
+     *
919
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
920
+     */
921
+    public function having(...$having) {
922
+        call_user_func_array(
923
+            [$this->queryBuilder, 'having'],
924
+            $having
925
+        );
926
+
927
+        return $this;
928
+    }
929
+
930
+    /**
931
+     * Adds a restriction over the groups of the query, forming a logical
932
+     * conjunction with any existing having restrictions.
933
+     *
934
+     * @param mixed ...$having The restriction to append.
935
+     *
936
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
937
+     */
938
+    public function andHaving(...$having) {
939
+        call_user_func_array(
940
+            [$this->queryBuilder, 'andHaving'],
941
+            $having
942
+        );
943
+
944
+        return $this;
945
+    }
946
+
947
+    /**
948
+     * Adds a restriction over the groups of the query, forming a logical
949
+     * disjunction with any existing having restrictions.
950
+     *
951
+     * @param mixed ...$having The restriction to add.
952
+     *
953
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
954
+     */
955
+    public function orHaving(...$having) {
956
+        call_user_func_array(
957
+            [$this->queryBuilder, 'orHaving'],
958
+            $having
959
+        );
960
+
961
+        return $this;
962
+    }
963
+
964
+    /**
965
+     * Specifies an ordering for the query results.
966
+     * Replaces any previously specified orderings, if any.
967
+     *
968
+     * @param string $sort The ordering expression.
969
+     * @param string $order The ordering direction.
970
+     *
971
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
972
+     */
973
+    public function orderBy($sort, $order = null) {
974
+        $this->queryBuilder->orderBy(
975
+            $this->helper->quoteColumnName($sort),
976
+            $order
977
+        );
978
+
979
+        return $this;
980
+    }
981
+
982
+    /**
983
+     * Adds an ordering to the query results.
984
+     *
985
+     * @param string $sort The ordering expression.
986
+     * @param string $order The ordering direction.
987
+     *
988
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
989
+     */
990
+    public function addOrderBy($sort, $order = null) {
991
+        $this->queryBuilder->addOrderBy(
992
+            $this->helper->quoteColumnName($sort),
993
+            $order
994
+        );
995
+
996
+        return $this;
997
+    }
998
+
999
+    /**
1000
+     * Gets a query part by its name.
1001
+     *
1002
+     * @param string $queryPartName
1003
+     *
1004
+     * @return mixed
1005
+     */
1006
+    public function getQueryPart($queryPartName) {
1007
+        return $this->queryBuilder->getQueryPart($queryPartName);
1008
+    }
1009
+
1010
+    /**
1011
+     * Gets all query parts.
1012
+     *
1013
+     * @return array
1014
+     */
1015
+    public function getQueryParts() {
1016
+        return $this->queryBuilder->getQueryParts();
1017
+    }
1018
+
1019
+    /**
1020
+     * Resets SQL parts.
1021
+     *
1022
+     * @param array|null $queryPartNames
1023
+     *
1024
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
1025
+     */
1026
+    public function resetQueryParts($queryPartNames = null) {
1027
+        $this->queryBuilder->resetQueryParts($queryPartNames);
1028
+
1029
+        return $this;
1030
+    }
1031
+
1032
+    /**
1033
+     * Resets a single SQL part.
1034
+     *
1035
+     * @param string $queryPartName
1036
+     *
1037
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
1038
+     */
1039
+    public function resetQueryPart($queryPartName) {
1040
+        $this->queryBuilder->resetQueryPart($queryPartName);
1041
+
1042
+        return $this;
1043
+    }
1044
+
1045
+    /**
1046
+     * Creates a new named parameter and bind the value $value to it.
1047
+     *
1048
+     * This method provides a shortcut for PDOStatement::bindValue
1049
+     * when using prepared statements.
1050
+     *
1051
+     * The parameter $value specifies the value that you want to bind. If
1052
+     * $placeholder is not provided bindValue() will automatically create a
1053
+     * placeholder for you. An automatic placeholder will be of the name
1054
+     * ':dcValue1', ':dcValue2' etc.
1055
+     *
1056
+     * For more information see {@link http://php.net/pdostatement-bindparam}
1057
+     *
1058
+     * Example:
1059
+     * <code>
1060
+     * $value = 2;
1061
+     * $q->eq( 'id', $q->bindValue( $value ) );
1062
+     * $stmt = $q->executeQuery(); // executed with 'id = 2'
1063
+     * </code>
1064
+     *
1065
+     * @license New BSD License
1066
+     * @link http://www.zetacomponents.org
1067
+     *
1068
+     * @param mixed $value
1069
+     * @param mixed $type
1070
+     * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
1071
+     *
1072
+     * @return IParameter the placeholder name used.
1073
+     */
1074
+    public function createNamedParameter($value, $type = IQueryBuilder::PARAM_STR, $placeHolder = null) {
1075
+        return new Parameter($this->queryBuilder->createNamedParameter($value, $type, $placeHolder));
1076
+    }
1077
+
1078
+    /**
1079
+     * Creates a new positional parameter and bind the given value to it.
1080
+     *
1081
+     * Attention: If you are using positional parameters with the query builder you have
1082
+     * to be very careful to bind all parameters in the order they appear in the SQL
1083
+     * statement , otherwise they get bound in the wrong order which can lead to serious
1084
+     * bugs in your code.
1085
+     *
1086
+     * Example:
1087
+     * <code>
1088
+     *  $qb = $conn->getQueryBuilder();
1089
+     *  $qb->select('u.*')
1090
+     *     ->from('users', 'u')
1091
+     *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
1092
+     *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
1093
+     * </code>
1094
+     *
1095
+     * @param mixed $value
1096
+     * @param integer $type
1097
+     *
1098
+     * @return IParameter
1099
+     */
1100
+    public function createPositionalParameter($value, $type = IQueryBuilder::PARAM_STR) {
1101
+        return new Parameter($this->queryBuilder->createPositionalParameter($value, $type));
1102
+    }
1103
+
1104
+    /**
1105
+     * Creates a new parameter
1106
+     *
1107
+     * Example:
1108
+     * <code>
1109
+     *  $qb = $conn->getQueryBuilder();
1110
+     *  $qb->select('u.*')
1111
+     *     ->from('users', 'u')
1112
+     *     ->where('u.username = ' . $qb->createParameter('name'))
1113
+     *     ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))
1114
+     * </code>
1115
+     *
1116
+     * @param string $name
1117
+     *
1118
+     * @return IParameter
1119
+     */
1120
+    public function createParameter($name) {
1121
+        return new Parameter(':' . $name);
1122
+    }
1123
+
1124
+    /**
1125
+     * Creates a new function
1126
+     *
1127
+     * Attention: Column names inside the call have to be quoted before hand
1128
+     *
1129
+     * Example:
1130
+     * <code>
1131
+     *  $qb = $conn->getQueryBuilder();
1132
+     *  $qb->select($qb->createFunction('COUNT(*)'))
1133
+     *     ->from('users', 'u')
1134
+     *  echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u
1135
+     * </code>
1136
+     * <code>
1137
+     *  $qb = $conn->getQueryBuilder();
1138
+     *  $qb->select($qb->createFunction('COUNT(`column`)'))
1139
+     *     ->from('users', 'u')
1140
+     *  echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u
1141
+     * </code>
1142
+     *
1143
+     * @param string $call
1144
+     *
1145
+     * @return IQueryFunction
1146
+     */
1147
+    public function createFunction($call) {
1148
+        return new QueryFunction($call);
1149
+    }
1150
+
1151
+    /**
1152
+     * Used to get the id of the last inserted element
1153
+     * @return int
1154
+     * @throws \BadMethodCallException When being called before an insert query has been run.
1155
+     */
1156
+    public function getLastInsertId() {
1157
+        if ($this->getType() === \Doctrine\DBAL\Query\QueryBuilder::INSERT && $this->lastInsertedTable) {
1158
+            // lastInsertId() needs the prefix but no quotes
1159
+            $table = $this->prefixTableName($this->lastInsertedTable);
1160
+            return (int) $this->connection->lastInsertId($table);
1161
+        }
1162
+
1163
+        throw new \BadMethodCallException('Invalid call to getLastInsertId without using insert() before.');
1164
+    }
1165
+
1166
+    /**
1167
+     * Returns the table name quoted and with database prefix as needed by the implementation
1168
+     *
1169
+     * @param string $table
1170
+     * @return string
1171
+     */
1172
+    public function getTableName($table) {
1173
+        $table = $this->prefixTableName($table);
1174
+        return $this->helper->quoteColumnName($table);
1175
+    }
1176
+
1177
+    /**
1178
+     * Returns the table name with database prefix as needed by the implementation
1179
+     *
1180
+     * @param string $table
1181
+     * @return string
1182
+     */
1183
+    protected function prefixTableName($table) {
1184
+        if ($this->automaticTablePrefix === false || strpos($table, '*PREFIX*') === 0) {
1185
+            return $table;
1186
+        }
1187
+
1188
+        return '*PREFIX*' . $table;
1189
+    }
1190
+
1191
+    /**
1192
+     * Returns the column name quoted and with table alias prefix as needed by the implementation
1193
+     *
1194
+     * @param string $column
1195
+     * @param string $tableAlias
1196
+     * @return string
1197
+     */
1198
+    public function getColumnName($column, $tableAlias = '') {
1199
+        if ($tableAlias !== '') {
1200
+            $tableAlias .= '.';
1201
+        }
1202
+
1203
+        return $this->helper->quoteColumnName($tableAlias . $column);
1204
+    }
1205
+
1206
+    /**
1207
+     * Returns the column name quoted and with table alias prefix as needed by the implementation
1208
+     *
1209
+     * @param string $alias
1210
+     * @return string
1211
+     */
1212
+    public function quoteAlias($alias) {
1213
+        if ($alias === '' || $alias === null) {
1214
+            return $alias;
1215
+        }
1216
+
1217
+        return $this->helper->quoteColumnName($alias);
1218
+    }
1219 1219
 }
Please login to merge, or discard this patch.