Passed
Push — master ( 7b83da...1b21b1 )
by Daniel
13:38 queued 14s
created
lib/public/DB/QueryBuilder/IQueryBuilder.php 1 patch
Indentation   +970 added lines, -970 removed lines patch added patch discarded remove patch
@@ -40,974 +40,974 @@
 block discarded – undo
40 40
  */
41 41
 interface IQueryBuilder {
42 42
 
43
-	/**
44
-	 * @since 9.0.0
45
-	 */
46
-	public const PARAM_NULL = \PDO::PARAM_NULL;
47
-	/**
48
-	 * @since 9.0.0
49
-	 */
50
-	public const PARAM_BOOL = \PDO::PARAM_BOOL;
51
-	/**
52
-	 * @since 9.0.0
53
-	 */
54
-	public const PARAM_INT = \PDO::PARAM_INT;
55
-	/**
56
-	 * @since 9.0.0
57
-	 */
58
-	public const PARAM_STR = \PDO::PARAM_STR;
59
-	/**
60
-	 * @since 9.0.0
61
-	 */
62
-	public const PARAM_LOB = \PDO::PARAM_LOB;
63
-	/**
64
-	 * @since 9.0.0
65
-	 */
66
-	public const PARAM_DATE = 'datetime';
67
-
68
-	/**
69
-	 * @since 9.0.0
70
-	 */
71
-	public const PARAM_INT_ARRAY = Connection::PARAM_INT_ARRAY;
72
-	/**
73
-	 * @since 9.0.0
74
-	 */
75
-	public const PARAM_STR_ARRAY = Connection::PARAM_STR_ARRAY;
76
-
77
-
78
-	/**
79
-	 * Enable/disable automatic prefixing of table names with the oc_ prefix
80
-	 *
81
-	 * @param bool $enabled If set to true table names will be prefixed with the
82
-	 * owncloud database prefix automatically.
83
-	 * @since 8.2.0
84
-	 */
85
-	public function automaticTablePrefix($enabled);
86
-
87
-	/**
88
-	 * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
89
-	 * This producer method is intended for convenient inline usage. Example:
90
-	 *
91
-	 * <code>
92
-	 *     $qb = $conn->getQueryBuilder()
93
-	 *         ->select('u')
94
-	 *         ->from('users', 'u')
95
-	 *         ->where($qb->expr()->eq('u.id', 1));
96
-	 * </code>
97
-	 *
98
-	 * For more complex expression construction, consider storing the expression
99
-	 * builder object in a local variable.
100
-	 *
101
-	 * @return \OCP\DB\QueryBuilder\IExpressionBuilder
102
-	 * @since 8.2.0
103
-	 */
104
-	public function expr();
105
-
106
-	/**
107
-	 * Gets an FunctionBuilder used for object-oriented construction of query functions.
108
-	 * This producer method is intended for convenient inline usage. Example:
109
-	 *
110
-	 * <code>
111
-	 *     $qb = $conn->getQueryBuilder()
112
-	 *         ->select('u')
113
-	 *         ->from('users', 'u')
114
-	 *         ->where($qb->fun()->md5('u.id'));
115
-	 * </code>
116
-	 *
117
-	 * For more complex function construction, consider storing the function
118
-	 * builder object in a local variable.
119
-	 *
120
-	 * @return \OCP\DB\QueryBuilder\IFunctionBuilder
121
-	 * @since 12.0.0
122
-	 */
123
-	public function func();
124
-
125
-	/**
126
-	 * Gets the type of the currently built query.
127
-	 *
128
-	 * @return integer
129
-	 * @since 8.2.0
130
-	 */
131
-	public function getType();
132
-
133
-	/**
134
-	 * Gets the associated DBAL Connection for this query builder.
135
-	 *
136
-	 * @return \OCP\IDBConnection
137
-	 * @since 8.2.0
138
-	 */
139
-	public function getConnection();
140
-
141
-	/**
142
-	 * Gets the state of this query builder instance.
143
-	 *
144
-	 * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.
145
-	 * @since 8.2.0
146
-	 */
147
-	public function getState();
148
-
149
-	/**
150
-	 * Executes this query using the bound parameters and their types.
151
-	 *
152
-	 * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeStatement}
153
-	 * for insert, update and delete statements.
154
-	 *
155
-	 * Warning: until Nextcloud 20, this method could return a \Doctrine\DBAL\Driver\Statement but since
156
-	 *          that interface changed in a breaking way the adapter \OCP\DB\QueryBuilder\IStatement is returned
157
-	 *          to bridge old code to the new API
158
-	 *
159
-	 * @return IResult|int
160
-	 * @throws Exception since 21.0.0
161
-	 * @since 8.2.0
162
-	 * @deprecated 22.0.0 Use executeQuery or executeStatement
163
-	 */
164
-	public function execute();
165
-
166
-	/**
167
-	 * Execute for select statements
168
-	 *
169
-	 * @return IResult
170
-	 * @since 22.0.0
171
-	 *
172
-	 * @throws Exception
173
-	 * @throws \RuntimeException in case of usage with non select query
174
-	 */
175
-	public function executeQuery(): IResult;
176
-
177
-	/**
178
-	 * Execute insert, update and delete statements
179
-	 *
180
-	 * @return int the number of affected rows
181
-	 * @since 22.0.0
182
-	 *
183
-	 * @throws Exception
184
-	 * @throws \RuntimeException in case of usage with select query
185
-	 */
186
-	public function executeStatement(): int;
187
-
188
-	/**
189
-	 * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
190
-	 *
191
-	 * <code>
192
-	 *     $qb = $conn->getQueryBuilder()
193
-	 *         ->select('u')
194
-	 *         ->from('User', 'u')
195
-	 *     echo $qb->getSQL(); // SELECT u FROM User u
196
-	 * </code>
197
-	 *
198
-	 * @return string The SQL query string.
199
-	 * @since 8.2.0
200
-	 */
201
-	public function getSQL();
202
-
203
-	/**
204
-	 * Sets a query parameter for the query being constructed.
205
-	 *
206
-	 * <code>
207
-	 *     $qb = $conn->getQueryBuilder()
208
-	 *         ->select('u')
209
-	 *         ->from('users', 'u')
210
-	 *         ->where('u.id = :user_id')
211
-	 *         ->setParameter(':user_id', 1);
212
-	 * </code>
213
-	 *
214
-	 * @param string|integer $key The parameter position or name.
215
-	 * @param mixed $value The parameter value.
216
-	 * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
217
-	 *
218
-	 * @return $this This QueryBuilder instance.
219
-	 * @since 8.2.0
220
-	 */
221
-	public function setParameter($key, $value, $type = null);
222
-
223
-	/**
224
-	 * Sets a collection of query parameters for the query being constructed.
225
-	 *
226
-	 * <code>
227
-	 *     $qb = $conn->getQueryBuilder()
228
-	 *         ->select('u')
229
-	 *         ->from('users', 'u')
230
-	 *         ->where('u.id = :user_id1 OR u.id = :user_id2')
231
-	 *         ->setParameters(array(
232
-	 *             ':user_id1' => 1,
233
-	 *             ':user_id2' => 2
234
-	 *         ));
235
-	 * </code>
236
-	 *
237
-	 * @param array $params The query parameters to set.
238
-	 * @param array $types The query parameters types to set.
239
-	 *
240
-	 * @return $this This QueryBuilder instance.
241
-	 * @since 8.2.0
242
-	 */
243
-	public function setParameters(array $params, array $types = []);
244
-
245
-	/**
246
-	 * Gets all defined query parameters for the query being constructed indexed by parameter index or name.
247
-	 *
248
-	 * @return array The currently defined query parameters indexed by parameter index or name.
249
-	 * @since 8.2.0
250
-	 */
251
-	public function getParameters();
252
-
253
-	/**
254
-	 * Gets a (previously set) query parameter of the query being constructed.
255
-	 *
256
-	 * @param mixed $key The key (index or name) of the bound parameter.
257
-	 *
258
-	 * @return mixed The value of the bound parameter.
259
-	 * @since 8.2.0
260
-	 */
261
-	public function getParameter($key);
262
-
263
-	/**
264
-	 * Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
265
-	 *
266
-	 * @return array The currently defined query parameter types indexed by parameter index or name.
267
-	 * @since 8.2.0
268
-	 */
269
-	public function getParameterTypes();
270
-
271
-	/**
272
-	 * Gets a (previously set) query parameter type of the query being constructed.
273
-	 *
274
-	 * @param mixed $key The key (index or name) of the bound parameter type.
275
-	 *
276
-	 * @return mixed The value of the bound parameter type.
277
-	 * @since 8.2.0
278
-	 */
279
-	public function getParameterType($key);
280
-
281
-	/**
282
-	 * Sets the position of the first result to retrieve (the "offset").
283
-	 *
284
-	 * @param integer $firstResult The first result to return.
285
-	 *
286
-	 * @return $this This QueryBuilder instance.
287
-	 * @since 8.2.0
288
-	 */
289
-	public function setFirstResult($firstResult);
290
-
291
-	/**
292
-	 * Gets the position of the first result the query object was set to retrieve (the "offset").
293
-	 * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
294
-	 *
295
-	 * @return integer The position of the first result.
296
-	 * @since 8.2.0
297
-	 */
298
-	public function getFirstResult();
299
-
300
-	/**
301
-	 * Sets the maximum number of results to retrieve (the "limit").
302
-	 *
303
-	 * @param integer $maxResults The maximum number of results to retrieve.
304
-	 *
305
-	 * @return $this This QueryBuilder instance.
306
-	 * @since 8.2.0
307
-	 */
308
-	public function setMaxResults($maxResults);
309
-
310
-	/**
311
-	 * Gets the maximum number of results the query object was set to retrieve (the "limit").
312
-	 * Returns NULL if {@link setMaxResults} was not applied to this query builder.
313
-	 *
314
-	 * @return int|null The maximum number of results.
315
-	 * @since 8.2.0
316
-	 */
317
-	public function getMaxResults();
318
-
319
-	/**
320
-	 * Specifies an item that is to be returned in the query result.
321
-	 * Replaces any previously specified selections, if any.
322
-	 *
323
-	 * <code>
324
-	 *     $qb = $conn->getQueryBuilder()
325
-	 *         ->select('u.id', 'p.id')
326
-	 *         ->from('users', 'u')
327
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
328
-	 * </code>
329
-	 *
330
-	 * @param mixed ...$selects The selection expressions.
331
-	 *
332
-	 * @return $this This QueryBuilder instance.
333
-	 * @since 8.2.0
334
-	 *
335
-	 * @psalm-taint-sink sql $selects
336
-	 */
337
-	public function select(...$selects);
338
-
339
-	/**
340
-	 * Specifies an item that is to be returned with a different name in the query result.
341
-	 *
342
-	 * <code>
343
-	 *     $qb = $conn->getQueryBuilder()
344
-	 *         ->selectAlias('u.id', 'user_id')
345
-	 *         ->from('users', 'u')
346
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
347
-	 * </code>
348
-	 *
349
-	 * @param mixed $select The selection expressions.
350
-	 * @param string $alias The column alias used in the constructed query.
351
-	 *
352
-	 * @return $this This QueryBuilder instance.
353
-	 * @since 8.2.1
354
-	 *
355
-	 * @psalm-taint-sink sql $select
356
-	 * @psalm-taint-sink sql $alias
357
-	 */
358
-	public function selectAlias($select, $alias);
359
-
360
-	/**
361
-	 * Specifies an item that is to be returned uniquely in the query result.
362
-	 *
363
-	 * <code>
364
-	 *     $qb = $conn->getQueryBuilder()
365
-	 *         ->selectDistinct('type')
366
-	 *         ->from('users');
367
-	 * </code>
368
-	 *
369
-	 * @param mixed $select The selection expressions.
370
-	 *
371
-	 * @return $this This QueryBuilder instance.
372
-	 * @since 9.0.0
373
-	 *
374
-	 * @psalm-taint-sink sql $select
375
-	 */
376
-	public function selectDistinct($select);
377
-
378
-	/**
379
-	 * Adds an item that is to be returned in the query result.
380
-	 *
381
-	 * <code>
382
-	 *     $qb = $conn->getQueryBuilder()
383
-	 *         ->select('u.id')
384
-	 *         ->addSelect('p.id')
385
-	 *         ->from('users', 'u')
386
-	 *         ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
387
-	 * </code>
388
-	 *
389
-	 * @param mixed ...$select The selection expression.
390
-	 *
391
-	 * @return $this This QueryBuilder instance.
392
-	 * @since 8.2.0
393
-	 *
394
-	 * @psalm-taint-sink sql $select
395
-	 */
396
-	public function addSelect(...$select);
397
-
398
-	/**
399
-	 * Turns the query being built into a bulk delete query that ranges over
400
-	 * a certain table.
401
-	 *
402
-	 * <code>
403
-	 *     $qb = $conn->getQueryBuilder()
404
-	 *         ->delete('users', 'u')
405
-	 *         ->where('u.id = :user_id');
406
-	 *         ->setParameter(':user_id', 1);
407
-	 * </code>
408
-	 *
409
-	 * @param string $delete The table whose rows are subject to the deletion.
410
-	 * @param string $alias The table alias used in the constructed query.
411
-	 *
412
-	 * @return $this This QueryBuilder instance.
413
-	 * @since 8.2.0
414
-	 *
415
-	 * @psalm-taint-sink sql $delete
416
-	 */
417
-	public function delete($delete = null, $alias = null);
418
-
419
-	/**
420
-	 * Turns the query being built into a bulk update query that ranges over
421
-	 * a certain table
422
-	 *
423
-	 * <code>
424
-	 *     $qb = $conn->getQueryBuilder()
425
-	 *         ->update('users', 'u')
426
-	 *         ->set('u.password', md5('password'))
427
-	 *         ->where('u.id = ?');
428
-	 * </code>
429
-	 *
430
-	 * @param string $update The table whose rows are subject to the update.
431
-	 * @param string $alias The table alias used in the constructed query.
432
-	 *
433
-	 * @return $this This QueryBuilder instance.
434
-	 * @since 8.2.0
435
-	 *
436
-	 * @psalm-taint-sink sql $update
437
-	 */
438
-	public function update($update = null, $alias = null);
439
-
440
-	/**
441
-	 * Turns the query being built into an insert query that inserts into
442
-	 * a certain table
443
-	 *
444
-	 * <code>
445
-	 *     $qb = $conn->getQueryBuilder()
446
-	 *         ->insert('users')
447
-	 *         ->values(
448
-	 *             array(
449
-	 *                 'name' => '?',
450
-	 *                 'password' => '?'
451
-	 *             )
452
-	 *         );
453
-	 * </code>
454
-	 *
455
-	 * @param string $insert The table into which the rows should be inserted.
456
-	 *
457
-	 * @return $this This QueryBuilder instance.
458
-	 * @since 8.2.0
459
-	 *
460
-	 * @psalm-taint-sink sql $insert
461
-	 */
462
-	public function insert($insert = null);
463
-
464
-	/**
465
-	 * Creates and adds a query root corresponding to the table identified by the
466
-	 * given alias, forming a cartesian product with any existing query roots.
467
-	 *
468
-	 * <code>
469
-	 *     $qb = $conn->getQueryBuilder()
470
-	 *         ->select('u.id')
471
-	 *         ->from('users', 'u')
472
-	 * </code>
473
-	 *
474
-	 * @param string $from The table.
475
-	 * @param string|null $alias The alias of the table.
476
-	 *
477
-	 * @return $this This QueryBuilder instance.
478
-	 * @since 8.2.0
479
-	 *
480
-	 * @psalm-taint-sink sql $from
481
-	 */
482
-	public function from($from, $alias = null);
483
-
484
-	/**
485
-	 * Creates and adds a join to the query.
486
-	 *
487
-	 * <code>
488
-	 *     $qb = $conn->getQueryBuilder()
489
-	 *         ->select('u.name')
490
-	 *         ->from('users', 'u')
491
-	 *         ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
492
-	 * </code>
493
-	 *
494
-	 * @param string $fromAlias The alias that points to a from clause.
495
-	 * @param string $join The table name to join.
496
-	 * @param string $alias The alias of the join table.
497
-	 * @param string|ICompositeExpression|null $condition The condition for the join.
498
-	 *
499
-	 * @return $this This QueryBuilder instance.
500
-	 * @since 8.2.0
501
-	 *
502
-	 * @psalm-taint-sink sql $fromAlias
503
-	 * @psalm-taint-sink sql $join
504
-	 * @psalm-taint-sink sql $alias
505
-	 * @psalm-taint-sink sql $condition
506
-	 */
507
-	public function join($fromAlias, $join, $alias, $condition = null);
508
-
509
-	/**
510
-	 * Creates and adds a join to the query.
511
-	 *
512
-	 * <code>
513
-	 *     $qb = $conn->getQueryBuilder()
514
-	 *         ->select('u.name')
515
-	 *         ->from('users', 'u')
516
-	 *         ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
517
-	 * </code>
518
-	 *
519
-	 * @param string $fromAlias The alias that points to a from clause.
520
-	 * @param string $join The table name to join.
521
-	 * @param string $alias The alias of the join table.
522
-	 * @param string|ICompositeExpression|null $condition The condition for the join.
523
-	 *
524
-	 * @return $this This QueryBuilder instance.
525
-	 * @since 8.2.0
526
-	 *
527
-	 * @psalm-taint-sink sql $fromAlias
528
-	 * @psalm-taint-sink sql $join
529
-	 * @psalm-taint-sink sql $alias
530
-	 * @psalm-taint-sink sql $condition
531
-	 */
532
-	public function innerJoin($fromAlias, $join, $alias, $condition = null);
533
-
534
-	/**
535
-	 * Creates and adds a left join to the query.
536
-	 *
537
-	 * <code>
538
-	 *     $qb = $conn->getQueryBuilder()
539
-	 *         ->select('u.name')
540
-	 *         ->from('users', 'u')
541
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
542
-	 * </code>
543
-	 *
544
-	 * @param string $fromAlias The alias that points to a from clause.
545
-	 * @param string $join The table name to join.
546
-	 * @param string $alias The alias of the join table.
547
-	 * @param string|ICompositeExpression|null $condition The condition for the join.
548
-	 *
549
-	 * @return $this This QueryBuilder instance.
550
-	 * @since 8.2.0
551
-	 *
552
-	 * @psalm-taint-sink sql $fromAlias
553
-	 * @psalm-taint-sink sql $join
554
-	 * @psalm-taint-sink sql $alias
555
-	 * @psalm-taint-sink sql $condition
556
-	 */
557
-	public function leftJoin($fromAlias, $join, $alias, $condition = null);
558
-
559
-	/**
560
-	 * Creates and adds a right join to the query.
561
-	 *
562
-	 * <code>
563
-	 *     $qb = $conn->getQueryBuilder()
564
-	 *         ->select('u.name')
565
-	 *         ->from('users', 'u')
566
-	 *         ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
567
-	 * </code>
568
-	 *
569
-	 * @param string $fromAlias The alias that points to a from clause.
570
-	 * @param string $join The table name to join.
571
-	 * @param string $alias The alias of the join table.
572
-	 * @param string|ICompositeExpression|null $condition The condition for the join.
573
-	 *
574
-	 * @return $this This QueryBuilder instance.
575
-	 * @since 8.2.0
576
-	 *
577
-	 * @psalm-taint-sink sql $fromAlias
578
-	 * @psalm-taint-sink sql $join
579
-	 * @psalm-taint-sink sql $alias
580
-	 * @psalm-taint-sink sql $condition
581
-	 */
582
-	public function rightJoin($fromAlias, $join, $alias, $condition = null);
583
-
584
-	/**
585
-	 * Sets a new value for a column in a bulk update query.
586
-	 *
587
-	 * <code>
588
-	 *     $qb = $conn->getQueryBuilder()
589
-	 *         ->update('users', 'u')
590
-	 *         ->set('u.password', md5('password'))
591
-	 *         ->where('u.id = ?');
592
-	 * </code>
593
-	 *
594
-	 * @param string $key The column to set.
595
-	 * @param ILiteral|IParameter|IQueryFunction|string $value The value, expression, placeholder, etc.
596
-	 *
597
-	 * @return $this This QueryBuilder instance.
598
-	 * @since 8.2.0
599
-	 *
600
-	 * @psalm-taint-sink sql $key
601
-	 * @psalm-taint-sink sql $value
602
-	 */
603
-	public function set($key, $value);
604
-
605
-	/**
606
-	 * Specifies one or more restrictions to the query result.
607
-	 * Replaces any previously specified restrictions, if any.
608
-	 *
609
-	 * <code>
610
-	 *     $qb = $conn->getQueryBuilder()
611
-	 *         ->select('u.name')
612
-	 *         ->from('users', 'u')
613
-	 *         ->where('u.id = ?');
614
-	 *
615
-	 *     // You can optionally programatically build and/or expressions
616
-	 *     $qb = $conn->getQueryBuilder();
617
-	 *
618
-	 *     $or = $qb->expr()->orx();
619
-	 *     $or->add($qb->expr()->eq('u.id', 1));
620
-	 *     $or->add($qb->expr()->eq('u.id', 2));
621
-	 *
622
-	 *     $qb->update('users', 'u')
623
-	 *         ->set('u.password', md5('password'))
624
-	 *         ->where($or);
625
-	 * </code>
626
-	 *
627
-	 * @param mixed $predicates The restriction predicates.
628
-	 *
629
-	 * @return $this This QueryBuilder instance.
630
-	 * @since 8.2.0
631
-	 *
632
-	 * @psalm-taint-sink sql $predicates
633
-	 */
634
-	public function where(...$predicates);
635
-
636
-	/**
637
-	 * Adds one or more restrictions to the query results, forming a logical
638
-	 * conjunction with any previously specified restrictions.
639
-	 *
640
-	 * <code>
641
-	 *     $qb = $conn->getQueryBuilder()
642
-	 *         ->select('u')
643
-	 *         ->from('users', 'u')
644
-	 *         ->where('u.username LIKE ?')
645
-	 *         ->andWhere('u.is_active = 1');
646
-	 * </code>
647
-	 *
648
-	 * @param mixed ...$where The query restrictions.
649
-	 *
650
-	 * @return $this This QueryBuilder instance.
651
-	 *
652
-	 * @see where()
653
-	 * @since 8.2.0
654
-	 *
655
-	 * @psalm-taint-sink sql $where
656
-	 */
657
-	public function andWhere(...$where);
658
-
659
-	/**
660
-	 * Adds one or more restrictions to the query results, forming a logical
661
-	 * disjunction with any previously specified restrictions.
662
-	 *
663
-	 * <code>
664
-	 *     $qb = $conn->getQueryBuilder()
665
-	 *         ->select('u.name')
666
-	 *         ->from('users', 'u')
667
-	 *         ->where('u.id = 1')
668
-	 *         ->orWhere('u.id = 2');
669
-	 * </code>
670
-	 *
671
-	 * @param mixed ...$where The WHERE statement.
672
-	 *
673
-	 * @return $this This QueryBuilder instance.
674
-	 *
675
-	 * @see where()
676
-	 * @since 8.2.0
677
-	 *
678
-	 * @psalm-taint-sink sql $where
679
-	 */
680
-	public function orWhere(...$where);
681
-
682
-	/**
683
-	 * Specifies a grouping over the results of the query.
684
-	 * Replaces any previously specified groupings, if any.
685
-	 *
686
-	 * <code>
687
-	 *     $qb = $conn->getQueryBuilder()
688
-	 *         ->select('u.name')
689
-	 *         ->from('users', 'u')
690
-	 *         ->groupBy('u.id');
691
-	 * </code>
692
-	 *
693
-	 * @param mixed ...$groupBys The grouping expression.
694
-	 *
695
-	 * @return $this This QueryBuilder instance.
696
-	 * @since 8.2.0
697
-	 *
698
-	 * @psalm-taint-sink sql $groupBys
699
-	 */
700
-	public function groupBy(...$groupBys);
701
-
702
-	/**
703
-	 * Adds a grouping expression to the query.
704
-	 *
705
-	 * <code>
706
-	 *     $qb = $conn->getQueryBuilder()
707
-	 *         ->select('u.name')
708
-	 *         ->from('users', 'u')
709
-	 *         ->groupBy('u.lastLogin');
710
-	 *         ->addGroupBy('u.createdAt')
711
-	 * </code>
712
-	 *
713
-	 * @param mixed ...$groupBy The grouping expression.
714
-	 *
715
-	 * @return $this This QueryBuilder instance.
716
-	 * @since 8.2.0
717
-	 *
718
-	 * @psalm-taint-sink sql $groupby
719
-	 */
720
-	public function addGroupBy(...$groupBy);
721
-
722
-	/**
723
-	 * Sets a value for a column in an insert query.
724
-	 *
725
-	 * <code>
726
-	 *     $qb = $conn->getQueryBuilder()
727
-	 *         ->insert('users')
728
-	 *         ->values(
729
-	 *             array(
730
-	 *                 'name' => '?'
731
-	 *             )
732
-	 *         )
733
-	 *         ->setValue('password', '?');
734
-	 * </code>
735
-	 *
736
-	 * @param string $column The column into which the value should be inserted.
737
-	 * @param IParameter|string $value The value that should be inserted into the column.
738
-	 *
739
-	 * @return $this This QueryBuilder instance.
740
-	 * @since 8.2.0
741
-	 *
742
-	 * @psalm-taint-sink sql $column
743
-	 * @psalm-taint-sink sql $value
744
-	 */
745
-	public function setValue($column, $value);
746
-
747
-	/**
748
-	 * Specifies values for an insert query indexed by column names.
749
-	 * Replaces any previous values, if any.
750
-	 *
751
-	 * <code>
752
-	 *     $qb = $conn->getQueryBuilder()
753
-	 *         ->insert('users')
754
-	 *         ->values(
755
-	 *             array(
756
-	 *                 'name' => '?',
757
-	 *                 'password' => '?'
758
-	 *             )
759
-	 *         );
760
-	 * </code>
761
-	 *
762
-	 * @param array $values The values to specify for the insert query indexed by column names.
763
-	 *
764
-	 * @return $this This QueryBuilder instance.
765
-	 * @since 8.2.0
766
-	 *
767
-	 * @psalm-taint-sink sql $values
768
-	 */
769
-	public function values(array $values);
770
-
771
-	/**
772
-	 * Specifies a restriction over the groups of the query.
773
-	 * Replaces any previous having restrictions, if any.
774
-	 *
775
-	 * @param mixed ...$having The restriction over the groups.
776
-	 *
777
-	 * @return $this This QueryBuilder instance.
778
-	 * @since 8.2.0
779
-	 *
780
-	 * @psalm-taint-sink sql $having
781
-	 */
782
-	public function having(...$having);
783
-
784
-	/**
785
-	 * Adds a restriction over the groups of the query, forming a logical
786
-	 * conjunction with any existing having restrictions.
787
-	 *
788
-	 * @param mixed ...$having The restriction to append.
789
-	 *
790
-	 * @return $this This QueryBuilder instance.
791
-	 * @since 8.2.0
792
-	 *
793
-	 * @psalm-taint-sink sql $andHaving
794
-	 */
795
-	public function andHaving(...$having);
796
-
797
-	/**
798
-	 * Adds a restriction over the groups of the query, forming a logical
799
-	 * disjunction with any existing having restrictions.
800
-	 *
801
-	 * @param mixed ...$having The restriction to add.
802
-	 *
803
-	 * @return $this This QueryBuilder instance.
804
-	 * @since 8.2.0
805
-	 *
806
-	 * @psalm-taint-sink sql $having
807
-	 */
808
-	public function orHaving(...$having);
809
-
810
-	/**
811
-	 * Specifies an ordering for the query results.
812
-	 * Replaces any previously specified orderings, if any.
813
-	 *
814
-	 * @param string $sort The ordering expression.
815
-	 * @param string $order The ordering direction.
816
-	 *
817
-	 * @return $this This QueryBuilder instance.
818
-	 * @since 8.2.0
819
-	 *
820
-	 * @psalm-taint-sink sql $sort
821
-	 * @psalm-taint-sink sql $order
822
-	 */
823
-	public function orderBy($sort, $order = null);
824
-
825
-	/**
826
-	 * Adds an ordering to the query results.
827
-	 *
828
-	 * @param string $sort The ordering expression.
829
-	 * @param string $order The ordering direction.
830
-	 *
831
-	 * @return $this This QueryBuilder instance.
832
-	 * @since 8.2.0
833
-	 *
834
-	 * @psalm-taint-sink sql $sort
835
-	 * @psalm-taint-sink sql $order
836
-	 */
837
-	public function addOrderBy($sort, $order = null);
838
-
839
-	/**
840
-	 * Gets a query part by its name.
841
-	 *
842
-	 * @param string $queryPartName
843
-	 *
844
-	 * @return mixed
845
-	 * @since 8.2.0
846
-	 */
847
-	public function getQueryPart($queryPartName);
848
-
849
-	/**
850
-	 * Gets all query parts.
851
-	 *
852
-	 * @return array
853
-	 * @since 8.2.0
854
-	 */
855
-	public function getQueryParts();
856
-
857
-	/**
858
-	 * Resets SQL parts.
859
-	 *
860
-	 * @param array|null $queryPartNames
861
-	 *
862
-	 * @return $this This QueryBuilder instance.
863
-	 * @since 8.2.0
864
-	 */
865
-	public function resetQueryParts($queryPartNames = null);
866
-
867
-	/**
868
-	 * Resets a single SQL part.
869
-	 *
870
-	 * @param string $queryPartName
871
-	 *
872
-	 * @return $this This QueryBuilder instance.
873
-	 * @since 8.2.0
874
-	 */
875
-	public function resetQueryPart($queryPartName);
876
-
877
-	/**
878
-	 * Creates a new named parameter and bind the value $value to it.
879
-	 *
880
-	 * This method provides a shortcut for PDOStatement::bindValue
881
-	 * when using prepared statements.
882
-	 *
883
-	 * The parameter $value specifies the value that you want to bind. If
884
-	 * $placeholder is not provided bindValue() will automatically create a
885
-	 * placeholder for you. An automatic placeholder will be of the name
886
-	 * ':dcValue1', ':dcValue2' etc.
887
-	 *
888
-	 * For more information see {@link https://www.php.net/pdostatement-bindparam}
889
-	 *
890
-	 * Example:
891
-	 * <code>
892
-	 * $value = 2;
893
-	 * $q->eq( 'id', $q->bindValue( $value ) );
894
-	 * $stmt = $q->executeQuery(); // executed with 'id = 2'
895
-	 * </code>
896
-	 *
897
-	 * @license New BSD License
898
-	 * @link http://www.zetacomponents.org
899
-	 *
900
-	 * @param mixed $value
901
-	 * @param mixed $type
902
-	 * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
903
-	 *
904
-	 * @return IParameter
905
-	 * @since 8.2.0
906
-	 *
907
-	 * @psalm-taint-escape sql
908
-	 */
909
-	public function createNamedParameter($value, $type = self::PARAM_STR, $placeHolder = null);
910
-
911
-	/**
912
-	 * Creates a new positional parameter and bind the given value to it.
913
-	 *
914
-	 * Attention: If you are using positional parameters with the query builder you have
915
-	 * to be very careful to bind all parameters in the order they appear in the SQL
916
-	 * statement , otherwise they get bound in the wrong order which can lead to serious
917
-	 * bugs in your code.
918
-	 *
919
-	 * Example:
920
-	 * <code>
921
-	 *  $qb = $conn->getQueryBuilder();
922
-	 *  $qb->select('u.*')
923
-	 *     ->from('users', 'u')
924
-	 *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
925
-	 *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
926
-	 * </code>
927
-	 *
928
-	 * @param mixed $value
929
-	 * @param integer $type
930
-	 *
931
-	 * @return IParameter
932
-	 * @since 8.2.0
933
-	 *
934
-	 * @psalm-taint-escape sql
935
-	 */
936
-	public function createPositionalParameter($value, $type = self::PARAM_STR);
937
-
938
-	/**
939
-	 * Creates a new parameter
940
-	 *
941
-	 * Example:
942
-	 * <code>
943
-	 *  $qb = $conn->getQueryBuilder();
944
-	 *  $qb->select('u.*')
945
-	 *     ->from('users', 'u')
946
-	 *     ->where('u.username = ' . $qb->createParameter('name'))
947
-	 *     ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))
948
-	 * </code>
949
-	 *
950
-	 * @param string $name
951
-	 *
952
-	 * @return IParameter
953
-	 * @since 8.2.0
954
-	 *
955
-	 * @psalm-taint-escape sql
956
-	 */
957
-	public function createParameter($name);
958
-
959
-	/**
960
-	 * Creates a new function
961
-	 *
962
-	 * Attention: Column names inside the call have to be quoted before hand
963
-	 *
964
-	 * Example:
965
-	 * <code>
966
-	 *  $qb = $conn->getQueryBuilder();
967
-	 *  $qb->select($qb->createFunction('COUNT(*)'))
968
-	 *     ->from('users', 'u')
969
-	 *  echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u
970
-	 * </code>
971
-	 * <code>
972
-	 *  $qb = $conn->getQueryBuilder();
973
-	 *  $qb->select($qb->createFunction('COUNT(`column`)'))
974
-	 *     ->from('users', 'u')
975
-	 *  echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u
976
-	 * </code>
977
-	 *
978
-	 * @param string $call
979
-	 *
980
-	 * @return IQueryFunction
981
-	 * @since 8.2.0
982
-	 *
983
-	 * @psalm-taint-sink sql
984
-	 */
985
-	public function createFunction($call);
986
-
987
-	/**
988
-	 * Used to get the id of the last inserted element
989
-	 * @return int
990
-	 * @throws \BadMethodCallException When being called before an insert query has been run.
991
-	 * @since 9.0.0
992
-	 */
993
-	public function getLastInsertId(): int;
994
-
995
-	/**
996
-	 * Returns the table name quoted and with database prefix as needed by the implementation
997
-	 *
998
-	 * @param string $table
999
-	 * @return string
1000
-	 * @since 9.0.0
1001
-	 */
1002
-	public function getTableName($table);
1003
-
1004
-	/**
1005
-	 * Returns the column name quoted and with table alias prefix as needed by the implementation
1006
-	 *
1007
-	 * @param string $column
1008
-	 * @param string $tableAlias
1009
-	 * @return string
1010
-	 * @since 9.0.0
1011
-	 */
1012
-	public function getColumnName($column, $tableAlias = '');
43
+    /**
44
+     * @since 9.0.0
45
+     */
46
+    public const PARAM_NULL = \PDO::PARAM_NULL;
47
+    /**
48
+     * @since 9.0.0
49
+     */
50
+    public const PARAM_BOOL = \PDO::PARAM_BOOL;
51
+    /**
52
+     * @since 9.0.0
53
+     */
54
+    public const PARAM_INT = \PDO::PARAM_INT;
55
+    /**
56
+     * @since 9.0.0
57
+     */
58
+    public const PARAM_STR = \PDO::PARAM_STR;
59
+    /**
60
+     * @since 9.0.0
61
+     */
62
+    public const PARAM_LOB = \PDO::PARAM_LOB;
63
+    /**
64
+     * @since 9.0.0
65
+     */
66
+    public const PARAM_DATE = 'datetime';
67
+
68
+    /**
69
+     * @since 9.0.0
70
+     */
71
+    public const PARAM_INT_ARRAY = Connection::PARAM_INT_ARRAY;
72
+    /**
73
+     * @since 9.0.0
74
+     */
75
+    public const PARAM_STR_ARRAY = Connection::PARAM_STR_ARRAY;
76
+
77
+
78
+    /**
79
+     * Enable/disable automatic prefixing of table names with the oc_ prefix
80
+     *
81
+     * @param bool $enabled If set to true table names will be prefixed with the
82
+     * owncloud database prefix automatically.
83
+     * @since 8.2.0
84
+     */
85
+    public function automaticTablePrefix($enabled);
86
+
87
+    /**
88
+     * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
89
+     * This producer method is intended for convenient inline usage. Example:
90
+     *
91
+     * <code>
92
+     *     $qb = $conn->getQueryBuilder()
93
+     *         ->select('u')
94
+     *         ->from('users', 'u')
95
+     *         ->where($qb->expr()->eq('u.id', 1));
96
+     * </code>
97
+     *
98
+     * For more complex expression construction, consider storing the expression
99
+     * builder object in a local variable.
100
+     *
101
+     * @return \OCP\DB\QueryBuilder\IExpressionBuilder
102
+     * @since 8.2.0
103
+     */
104
+    public function expr();
105
+
106
+    /**
107
+     * Gets an FunctionBuilder used for object-oriented construction of query functions.
108
+     * This producer method is intended for convenient inline usage. Example:
109
+     *
110
+     * <code>
111
+     *     $qb = $conn->getQueryBuilder()
112
+     *         ->select('u')
113
+     *         ->from('users', 'u')
114
+     *         ->where($qb->fun()->md5('u.id'));
115
+     * </code>
116
+     *
117
+     * For more complex function construction, consider storing the function
118
+     * builder object in a local variable.
119
+     *
120
+     * @return \OCP\DB\QueryBuilder\IFunctionBuilder
121
+     * @since 12.0.0
122
+     */
123
+    public function func();
124
+
125
+    /**
126
+     * Gets the type of the currently built query.
127
+     *
128
+     * @return integer
129
+     * @since 8.2.0
130
+     */
131
+    public function getType();
132
+
133
+    /**
134
+     * Gets the associated DBAL Connection for this query builder.
135
+     *
136
+     * @return \OCP\IDBConnection
137
+     * @since 8.2.0
138
+     */
139
+    public function getConnection();
140
+
141
+    /**
142
+     * Gets the state of this query builder instance.
143
+     *
144
+     * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.
145
+     * @since 8.2.0
146
+     */
147
+    public function getState();
148
+
149
+    /**
150
+     * Executes this query using the bound parameters and their types.
151
+     *
152
+     * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeStatement}
153
+     * for insert, update and delete statements.
154
+     *
155
+     * Warning: until Nextcloud 20, this method could return a \Doctrine\DBAL\Driver\Statement but since
156
+     *          that interface changed in a breaking way the adapter \OCP\DB\QueryBuilder\IStatement is returned
157
+     *          to bridge old code to the new API
158
+     *
159
+     * @return IResult|int
160
+     * @throws Exception since 21.0.0
161
+     * @since 8.2.0
162
+     * @deprecated 22.0.0 Use executeQuery or executeStatement
163
+     */
164
+    public function execute();
165
+
166
+    /**
167
+     * Execute for select statements
168
+     *
169
+     * @return IResult
170
+     * @since 22.0.0
171
+     *
172
+     * @throws Exception
173
+     * @throws \RuntimeException in case of usage with non select query
174
+     */
175
+    public function executeQuery(): IResult;
176
+
177
+    /**
178
+     * Execute insert, update and delete statements
179
+     *
180
+     * @return int the number of affected rows
181
+     * @since 22.0.0
182
+     *
183
+     * @throws Exception
184
+     * @throws \RuntimeException in case of usage with select query
185
+     */
186
+    public function executeStatement(): int;
187
+
188
+    /**
189
+     * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
190
+     *
191
+     * <code>
192
+     *     $qb = $conn->getQueryBuilder()
193
+     *         ->select('u')
194
+     *         ->from('User', 'u')
195
+     *     echo $qb->getSQL(); // SELECT u FROM User u
196
+     * </code>
197
+     *
198
+     * @return string The SQL query string.
199
+     * @since 8.2.0
200
+     */
201
+    public function getSQL();
202
+
203
+    /**
204
+     * Sets a query parameter for the query being constructed.
205
+     *
206
+     * <code>
207
+     *     $qb = $conn->getQueryBuilder()
208
+     *         ->select('u')
209
+     *         ->from('users', 'u')
210
+     *         ->where('u.id = :user_id')
211
+     *         ->setParameter(':user_id', 1);
212
+     * </code>
213
+     *
214
+     * @param string|integer $key The parameter position or name.
215
+     * @param mixed $value The parameter value.
216
+     * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
217
+     *
218
+     * @return $this This QueryBuilder instance.
219
+     * @since 8.2.0
220
+     */
221
+    public function setParameter($key, $value, $type = null);
222
+
223
+    /**
224
+     * Sets a collection of query parameters for the query being constructed.
225
+     *
226
+     * <code>
227
+     *     $qb = $conn->getQueryBuilder()
228
+     *         ->select('u')
229
+     *         ->from('users', 'u')
230
+     *         ->where('u.id = :user_id1 OR u.id = :user_id2')
231
+     *         ->setParameters(array(
232
+     *             ':user_id1' => 1,
233
+     *             ':user_id2' => 2
234
+     *         ));
235
+     * </code>
236
+     *
237
+     * @param array $params The query parameters to set.
238
+     * @param array $types The query parameters types to set.
239
+     *
240
+     * @return $this This QueryBuilder instance.
241
+     * @since 8.2.0
242
+     */
243
+    public function setParameters(array $params, array $types = []);
244
+
245
+    /**
246
+     * Gets all defined query parameters for the query being constructed indexed by parameter index or name.
247
+     *
248
+     * @return array The currently defined query parameters indexed by parameter index or name.
249
+     * @since 8.2.0
250
+     */
251
+    public function getParameters();
252
+
253
+    /**
254
+     * Gets a (previously set) query parameter of the query being constructed.
255
+     *
256
+     * @param mixed $key The key (index or name) of the bound parameter.
257
+     *
258
+     * @return mixed The value of the bound parameter.
259
+     * @since 8.2.0
260
+     */
261
+    public function getParameter($key);
262
+
263
+    /**
264
+     * Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
265
+     *
266
+     * @return array The currently defined query parameter types indexed by parameter index or name.
267
+     * @since 8.2.0
268
+     */
269
+    public function getParameterTypes();
270
+
271
+    /**
272
+     * Gets a (previously set) query parameter type of the query being constructed.
273
+     *
274
+     * @param mixed $key The key (index or name) of the bound parameter type.
275
+     *
276
+     * @return mixed The value of the bound parameter type.
277
+     * @since 8.2.0
278
+     */
279
+    public function getParameterType($key);
280
+
281
+    /**
282
+     * Sets the position of the first result to retrieve (the "offset").
283
+     *
284
+     * @param integer $firstResult The first result to return.
285
+     *
286
+     * @return $this This QueryBuilder instance.
287
+     * @since 8.2.0
288
+     */
289
+    public function setFirstResult($firstResult);
290
+
291
+    /**
292
+     * Gets the position of the first result the query object was set to retrieve (the "offset").
293
+     * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
294
+     *
295
+     * @return integer The position of the first result.
296
+     * @since 8.2.0
297
+     */
298
+    public function getFirstResult();
299
+
300
+    /**
301
+     * Sets the maximum number of results to retrieve (the "limit").
302
+     *
303
+     * @param integer $maxResults The maximum number of results to retrieve.
304
+     *
305
+     * @return $this This QueryBuilder instance.
306
+     * @since 8.2.0
307
+     */
308
+    public function setMaxResults($maxResults);
309
+
310
+    /**
311
+     * Gets the maximum number of results the query object was set to retrieve (the "limit").
312
+     * Returns NULL if {@link setMaxResults} was not applied to this query builder.
313
+     *
314
+     * @return int|null The maximum number of results.
315
+     * @since 8.2.0
316
+     */
317
+    public function getMaxResults();
318
+
319
+    /**
320
+     * Specifies an item that is to be returned in the query result.
321
+     * Replaces any previously specified selections, if any.
322
+     *
323
+     * <code>
324
+     *     $qb = $conn->getQueryBuilder()
325
+     *         ->select('u.id', 'p.id')
326
+     *         ->from('users', 'u')
327
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
328
+     * </code>
329
+     *
330
+     * @param mixed ...$selects The selection expressions.
331
+     *
332
+     * @return $this This QueryBuilder instance.
333
+     * @since 8.2.0
334
+     *
335
+     * @psalm-taint-sink sql $selects
336
+     */
337
+    public function select(...$selects);
338
+
339
+    /**
340
+     * Specifies an item that is to be returned with a different name in the query result.
341
+     *
342
+     * <code>
343
+     *     $qb = $conn->getQueryBuilder()
344
+     *         ->selectAlias('u.id', 'user_id')
345
+     *         ->from('users', 'u')
346
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
347
+     * </code>
348
+     *
349
+     * @param mixed $select The selection expressions.
350
+     * @param string $alias The column alias used in the constructed query.
351
+     *
352
+     * @return $this This QueryBuilder instance.
353
+     * @since 8.2.1
354
+     *
355
+     * @psalm-taint-sink sql $select
356
+     * @psalm-taint-sink sql $alias
357
+     */
358
+    public function selectAlias($select, $alias);
359
+
360
+    /**
361
+     * Specifies an item that is to be returned uniquely in the query result.
362
+     *
363
+     * <code>
364
+     *     $qb = $conn->getQueryBuilder()
365
+     *         ->selectDistinct('type')
366
+     *         ->from('users');
367
+     * </code>
368
+     *
369
+     * @param mixed $select The selection expressions.
370
+     *
371
+     * @return $this This QueryBuilder instance.
372
+     * @since 9.0.0
373
+     *
374
+     * @psalm-taint-sink sql $select
375
+     */
376
+    public function selectDistinct($select);
377
+
378
+    /**
379
+     * Adds an item that is to be returned in the query result.
380
+     *
381
+     * <code>
382
+     *     $qb = $conn->getQueryBuilder()
383
+     *         ->select('u.id')
384
+     *         ->addSelect('p.id')
385
+     *         ->from('users', 'u')
386
+     *         ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
387
+     * </code>
388
+     *
389
+     * @param mixed ...$select The selection expression.
390
+     *
391
+     * @return $this This QueryBuilder instance.
392
+     * @since 8.2.0
393
+     *
394
+     * @psalm-taint-sink sql $select
395
+     */
396
+    public function addSelect(...$select);
397
+
398
+    /**
399
+     * Turns the query being built into a bulk delete query that ranges over
400
+     * a certain table.
401
+     *
402
+     * <code>
403
+     *     $qb = $conn->getQueryBuilder()
404
+     *         ->delete('users', 'u')
405
+     *         ->where('u.id = :user_id');
406
+     *         ->setParameter(':user_id', 1);
407
+     * </code>
408
+     *
409
+     * @param string $delete The table whose rows are subject to the deletion.
410
+     * @param string $alias The table alias used in the constructed query.
411
+     *
412
+     * @return $this This QueryBuilder instance.
413
+     * @since 8.2.0
414
+     *
415
+     * @psalm-taint-sink sql $delete
416
+     */
417
+    public function delete($delete = null, $alias = null);
418
+
419
+    /**
420
+     * Turns the query being built into a bulk update query that ranges over
421
+     * a certain table
422
+     *
423
+     * <code>
424
+     *     $qb = $conn->getQueryBuilder()
425
+     *         ->update('users', 'u')
426
+     *         ->set('u.password', md5('password'))
427
+     *         ->where('u.id = ?');
428
+     * </code>
429
+     *
430
+     * @param string $update The table whose rows are subject to the update.
431
+     * @param string $alias The table alias used in the constructed query.
432
+     *
433
+     * @return $this This QueryBuilder instance.
434
+     * @since 8.2.0
435
+     *
436
+     * @psalm-taint-sink sql $update
437
+     */
438
+    public function update($update = null, $alias = null);
439
+
440
+    /**
441
+     * Turns the query being built into an insert query that inserts into
442
+     * a certain table
443
+     *
444
+     * <code>
445
+     *     $qb = $conn->getQueryBuilder()
446
+     *         ->insert('users')
447
+     *         ->values(
448
+     *             array(
449
+     *                 'name' => '?',
450
+     *                 'password' => '?'
451
+     *             )
452
+     *         );
453
+     * </code>
454
+     *
455
+     * @param string $insert The table into which the rows should be inserted.
456
+     *
457
+     * @return $this This QueryBuilder instance.
458
+     * @since 8.2.0
459
+     *
460
+     * @psalm-taint-sink sql $insert
461
+     */
462
+    public function insert($insert = null);
463
+
464
+    /**
465
+     * Creates and adds a query root corresponding to the table identified by the
466
+     * given alias, forming a cartesian product with any existing query roots.
467
+     *
468
+     * <code>
469
+     *     $qb = $conn->getQueryBuilder()
470
+     *         ->select('u.id')
471
+     *         ->from('users', 'u')
472
+     * </code>
473
+     *
474
+     * @param string $from The table.
475
+     * @param string|null $alias The alias of the table.
476
+     *
477
+     * @return $this This QueryBuilder instance.
478
+     * @since 8.2.0
479
+     *
480
+     * @psalm-taint-sink sql $from
481
+     */
482
+    public function from($from, $alias = null);
483
+
484
+    /**
485
+     * Creates and adds a join to the query.
486
+     *
487
+     * <code>
488
+     *     $qb = $conn->getQueryBuilder()
489
+     *         ->select('u.name')
490
+     *         ->from('users', 'u')
491
+     *         ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
492
+     * </code>
493
+     *
494
+     * @param string $fromAlias The alias that points to a from clause.
495
+     * @param string $join The table name to join.
496
+     * @param string $alias The alias of the join table.
497
+     * @param string|ICompositeExpression|null $condition The condition for the join.
498
+     *
499
+     * @return $this This QueryBuilder instance.
500
+     * @since 8.2.0
501
+     *
502
+     * @psalm-taint-sink sql $fromAlias
503
+     * @psalm-taint-sink sql $join
504
+     * @psalm-taint-sink sql $alias
505
+     * @psalm-taint-sink sql $condition
506
+     */
507
+    public function join($fromAlias, $join, $alias, $condition = null);
508
+
509
+    /**
510
+     * Creates and adds a join to the query.
511
+     *
512
+     * <code>
513
+     *     $qb = $conn->getQueryBuilder()
514
+     *         ->select('u.name')
515
+     *         ->from('users', 'u')
516
+     *         ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
517
+     * </code>
518
+     *
519
+     * @param string $fromAlias The alias that points to a from clause.
520
+     * @param string $join The table name to join.
521
+     * @param string $alias The alias of the join table.
522
+     * @param string|ICompositeExpression|null $condition The condition for the join.
523
+     *
524
+     * @return $this This QueryBuilder instance.
525
+     * @since 8.2.0
526
+     *
527
+     * @psalm-taint-sink sql $fromAlias
528
+     * @psalm-taint-sink sql $join
529
+     * @psalm-taint-sink sql $alias
530
+     * @psalm-taint-sink sql $condition
531
+     */
532
+    public function innerJoin($fromAlias, $join, $alias, $condition = null);
533
+
534
+    /**
535
+     * Creates and adds a left join to the query.
536
+     *
537
+     * <code>
538
+     *     $qb = $conn->getQueryBuilder()
539
+     *         ->select('u.name')
540
+     *         ->from('users', 'u')
541
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
542
+     * </code>
543
+     *
544
+     * @param string $fromAlias The alias that points to a from clause.
545
+     * @param string $join The table name to join.
546
+     * @param string $alias The alias of the join table.
547
+     * @param string|ICompositeExpression|null $condition The condition for the join.
548
+     *
549
+     * @return $this This QueryBuilder instance.
550
+     * @since 8.2.0
551
+     *
552
+     * @psalm-taint-sink sql $fromAlias
553
+     * @psalm-taint-sink sql $join
554
+     * @psalm-taint-sink sql $alias
555
+     * @psalm-taint-sink sql $condition
556
+     */
557
+    public function leftJoin($fromAlias, $join, $alias, $condition = null);
558
+
559
+    /**
560
+     * Creates and adds a right join to the query.
561
+     *
562
+     * <code>
563
+     *     $qb = $conn->getQueryBuilder()
564
+     *         ->select('u.name')
565
+     *         ->from('users', 'u')
566
+     *         ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
567
+     * </code>
568
+     *
569
+     * @param string $fromAlias The alias that points to a from clause.
570
+     * @param string $join The table name to join.
571
+     * @param string $alias The alias of the join table.
572
+     * @param string|ICompositeExpression|null $condition The condition for the join.
573
+     *
574
+     * @return $this This QueryBuilder instance.
575
+     * @since 8.2.0
576
+     *
577
+     * @psalm-taint-sink sql $fromAlias
578
+     * @psalm-taint-sink sql $join
579
+     * @psalm-taint-sink sql $alias
580
+     * @psalm-taint-sink sql $condition
581
+     */
582
+    public function rightJoin($fromAlias, $join, $alias, $condition = null);
583
+
584
+    /**
585
+     * Sets a new value for a column in a bulk update query.
586
+     *
587
+     * <code>
588
+     *     $qb = $conn->getQueryBuilder()
589
+     *         ->update('users', 'u')
590
+     *         ->set('u.password', md5('password'))
591
+     *         ->where('u.id = ?');
592
+     * </code>
593
+     *
594
+     * @param string $key The column to set.
595
+     * @param ILiteral|IParameter|IQueryFunction|string $value The value, expression, placeholder, etc.
596
+     *
597
+     * @return $this This QueryBuilder instance.
598
+     * @since 8.2.0
599
+     *
600
+     * @psalm-taint-sink sql $key
601
+     * @psalm-taint-sink sql $value
602
+     */
603
+    public function set($key, $value);
604
+
605
+    /**
606
+     * Specifies one or more restrictions to the query result.
607
+     * Replaces any previously specified restrictions, if any.
608
+     *
609
+     * <code>
610
+     *     $qb = $conn->getQueryBuilder()
611
+     *         ->select('u.name')
612
+     *         ->from('users', 'u')
613
+     *         ->where('u.id = ?');
614
+     *
615
+     *     // You can optionally programatically build and/or expressions
616
+     *     $qb = $conn->getQueryBuilder();
617
+     *
618
+     *     $or = $qb->expr()->orx();
619
+     *     $or->add($qb->expr()->eq('u.id', 1));
620
+     *     $or->add($qb->expr()->eq('u.id', 2));
621
+     *
622
+     *     $qb->update('users', 'u')
623
+     *         ->set('u.password', md5('password'))
624
+     *         ->where($or);
625
+     * </code>
626
+     *
627
+     * @param mixed $predicates The restriction predicates.
628
+     *
629
+     * @return $this This QueryBuilder instance.
630
+     * @since 8.2.0
631
+     *
632
+     * @psalm-taint-sink sql $predicates
633
+     */
634
+    public function where(...$predicates);
635
+
636
+    /**
637
+     * Adds one or more restrictions to the query results, forming a logical
638
+     * conjunction with any previously specified restrictions.
639
+     *
640
+     * <code>
641
+     *     $qb = $conn->getQueryBuilder()
642
+     *         ->select('u')
643
+     *         ->from('users', 'u')
644
+     *         ->where('u.username LIKE ?')
645
+     *         ->andWhere('u.is_active = 1');
646
+     * </code>
647
+     *
648
+     * @param mixed ...$where The query restrictions.
649
+     *
650
+     * @return $this This QueryBuilder instance.
651
+     *
652
+     * @see where()
653
+     * @since 8.2.0
654
+     *
655
+     * @psalm-taint-sink sql $where
656
+     */
657
+    public function andWhere(...$where);
658
+
659
+    /**
660
+     * Adds one or more restrictions to the query results, forming a logical
661
+     * disjunction with any previously specified restrictions.
662
+     *
663
+     * <code>
664
+     *     $qb = $conn->getQueryBuilder()
665
+     *         ->select('u.name')
666
+     *         ->from('users', 'u')
667
+     *         ->where('u.id = 1')
668
+     *         ->orWhere('u.id = 2');
669
+     * </code>
670
+     *
671
+     * @param mixed ...$where The WHERE statement.
672
+     *
673
+     * @return $this This QueryBuilder instance.
674
+     *
675
+     * @see where()
676
+     * @since 8.2.0
677
+     *
678
+     * @psalm-taint-sink sql $where
679
+     */
680
+    public function orWhere(...$where);
681
+
682
+    /**
683
+     * Specifies a grouping over the results of the query.
684
+     * Replaces any previously specified groupings, if any.
685
+     *
686
+     * <code>
687
+     *     $qb = $conn->getQueryBuilder()
688
+     *         ->select('u.name')
689
+     *         ->from('users', 'u')
690
+     *         ->groupBy('u.id');
691
+     * </code>
692
+     *
693
+     * @param mixed ...$groupBys The grouping expression.
694
+     *
695
+     * @return $this This QueryBuilder instance.
696
+     * @since 8.2.0
697
+     *
698
+     * @psalm-taint-sink sql $groupBys
699
+     */
700
+    public function groupBy(...$groupBys);
701
+
702
+    /**
703
+     * Adds a grouping expression to the query.
704
+     *
705
+     * <code>
706
+     *     $qb = $conn->getQueryBuilder()
707
+     *         ->select('u.name')
708
+     *         ->from('users', 'u')
709
+     *         ->groupBy('u.lastLogin');
710
+     *         ->addGroupBy('u.createdAt')
711
+     * </code>
712
+     *
713
+     * @param mixed ...$groupBy The grouping expression.
714
+     *
715
+     * @return $this This QueryBuilder instance.
716
+     * @since 8.2.0
717
+     *
718
+     * @psalm-taint-sink sql $groupby
719
+     */
720
+    public function addGroupBy(...$groupBy);
721
+
722
+    /**
723
+     * Sets a value for a column in an insert query.
724
+     *
725
+     * <code>
726
+     *     $qb = $conn->getQueryBuilder()
727
+     *         ->insert('users')
728
+     *         ->values(
729
+     *             array(
730
+     *                 'name' => '?'
731
+     *             )
732
+     *         )
733
+     *         ->setValue('password', '?');
734
+     * </code>
735
+     *
736
+     * @param string $column The column into which the value should be inserted.
737
+     * @param IParameter|string $value The value that should be inserted into the column.
738
+     *
739
+     * @return $this This QueryBuilder instance.
740
+     * @since 8.2.0
741
+     *
742
+     * @psalm-taint-sink sql $column
743
+     * @psalm-taint-sink sql $value
744
+     */
745
+    public function setValue($column, $value);
746
+
747
+    /**
748
+     * Specifies values for an insert query indexed by column names.
749
+     * Replaces any previous values, if any.
750
+     *
751
+     * <code>
752
+     *     $qb = $conn->getQueryBuilder()
753
+     *         ->insert('users')
754
+     *         ->values(
755
+     *             array(
756
+     *                 'name' => '?',
757
+     *                 'password' => '?'
758
+     *             )
759
+     *         );
760
+     * </code>
761
+     *
762
+     * @param array $values The values to specify for the insert query indexed by column names.
763
+     *
764
+     * @return $this This QueryBuilder instance.
765
+     * @since 8.2.0
766
+     *
767
+     * @psalm-taint-sink sql $values
768
+     */
769
+    public function values(array $values);
770
+
771
+    /**
772
+     * Specifies a restriction over the groups of the query.
773
+     * Replaces any previous having restrictions, if any.
774
+     *
775
+     * @param mixed ...$having The restriction over the groups.
776
+     *
777
+     * @return $this This QueryBuilder instance.
778
+     * @since 8.2.0
779
+     *
780
+     * @psalm-taint-sink sql $having
781
+     */
782
+    public function having(...$having);
783
+
784
+    /**
785
+     * Adds a restriction over the groups of the query, forming a logical
786
+     * conjunction with any existing having restrictions.
787
+     *
788
+     * @param mixed ...$having The restriction to append.
789
+     *
790
+     * @return $this This QueryBuilder instance.
791
+     * @since 8.2.0
792
+     *
793
+     * @psalm-taint-sink sql $andHaving
794
+     */
795
+    public function andHaving(...$having);
796
+
797
+    /**
798
+     * Adds a restriction over the groups of the query, forming a logical
799
+     * disjunction with any existing having restrictions.
800
+     *
801
+     * @param mixed ...$having The restriction to add.
802
+     *
803
+     * @return $this This QueryBuilder instance.
804
+     * @since 8.2.0
805
+     *
806
+     * @psalm-taint-sink sql $having
807
+     */
808
+    public function orHaving(...$having);
809
+
810
+    /**
811
+     * Specifies an ordering for the query results.
812
+     * Replaces any previously specified orderings, if any.
813
+     *
814
+     * @param string $sort The ordering expression.
815
+     * @param string $order The ordering direction.
816
+     *
817
+     * @return $this This QueryBuilder instance.
818
+     * @since 8.2.0
819
+     *
820
+     * @psalm-taint-sink sql $sort
821
+     * @psalm-taint-sink sql $order
822
+     */
823
+    public function orderBy($sort, $order = null);
824
+
825
+    /**
826
+     * Adds an ordering to the query results.
827
+     *
828
+     * @param string $sort The ordering expression.
829
+     * @param string $order The ordering direction.
830
+     *
831
+     * @return $this This QueryBuilder instance.
832
+     * @since 8.2.0
833
+     *
834
+     * @psalm-taint-sink sql $sort
835
+     * @psalm-taint-sink sql $order
836
+     */
837
+    public function addOrderBy($sort, $order = null);
838
+
839
+    /**
840
+     * Gets a query part by its name.
841
+     *
842
+     * @param string $queryPartName
843
+     *
844
+     * @return mixed
845
+     * @since 8.2.0
846
+     */
847
+    public function getQueryPart($queryPartName);
848
+
849
+    /**
850
+     * Gets all query parts.
851
+     *
852
+     * @return array
853
+     * @since 8.2.0
854
+     */
855
+    public function getQueryParts();
856
+
857
+    /**
858
+     * Resets SQL parts.
859
+     *
860
+     * @param array|null $queryPartNames
861
+     *
862
+     * @return $this This QueryBuilder instance.
863
+     * @since 8.2.0
864
+     */
865
+    public function resetQueryParts($queryPartNames = null);
866
+
867
+    /**
868
+     * Resets a single SQL part.
869
+     *
870
+     * @param string $queryPartName
871
+     *
872
+     * @return $this This QueryBuilder instance.
873
+     * @since 8.2.0
874
+     */
875
+    public function resetQueryPart($queryPartName);
876
+
877
+    /**
878
+     * Creates a new named parameter and bind the value $value to it.
879
+     *
880
+     * This method provides a shortcut for PDOStatement::bindValue
881
+     * when using prepared statements.
882
+     *
883
+     * The parameter $value specifies the value that you want to bind. If
884
+     * $placeholder is not provided bindValue() will automatically create a
885
+     * placeholder for you. An automatic placeholder will be of the name
886
+     * ':dcValue1', ':dcValue2' etc.
887
+     *
888
+     * For more information see {@link https://www.php.net/pdostatement-bindparam}
889
+     *
890
+     * Example:
891
+     * <code>
892
+     * $value = 2;
893
+     * $q->eq( 'id', $q->bindValue( $value ) );
894
+     * $stmt = $q->executeQuery(); // executed with 'id = 2'
895
+     * </code>
896
+     *
897
+     * @license New BSD License
898
+     * @link http://www.zetacomponents.org
899
+     *
900
+     * @param mixed $value
901
+     * @param mixed $type
902
+     * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
903
+     *
904
+     * @return IParameter
905
+     * @since 8.2.0
906
+     *
907
+     * @psalm-taint-escape sql
908
+     */
909
+    public function createNamedParameter($value, $type = self::PARAM_STR, $placeHolder = null);
910
+
911
+    /**
912
+     * Creates a new positional parameter and bind the given value to it.
913
+     *
914
+     * Attention: If you are using positional parameters with the query builder you have
915
+     * to be very careful to bind all parameters in the order they appear in the SQL
916
+     * statement , otherwise they get bound in the wrong order which can lead to serious
917
+     * bugs in your code.
918
+     *
919
+     * Example:
920
+     * <code>
921
+     *  $qb = $conn->getQueryBuilder();
922
+     *  $qb->select('u.*')
923
+     *     ->from('users', 'u')
924
+     *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
925
+     *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
926
+     * </code>
927
+     *
928
+     * @param mixed $value
929
+     * @param integer $type
930
+     *
931
+     * @return IParameter
932
+     * @since 8.2.0
933
+     *
934
+     * @psalm-taint-escape sql
935
+     */
936
+    public function createPositionalParameter($value, $type = self::PARAM_STR);
937
+
938
+    /**
939
+     * Creates a new parameter
940
+     *
941
+     * Example:
942
+     * <code>
943
+     *  $qb = $conn->getQueryBuilder();
944
+     *  $qb->select('u.*')
945
+     *     ->from('users', 'u')
946
+     *     ->where('u.username = ' . $qb->createParameter('name'))
947
+     *     ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))
948
+     * </code>
949
+     *
950
+     * @param string $name
951
+     *
952
+     * @return IParameter
953
+     * @since 8.2.0
954
+     *
955
+     * @psalm-taint-escape sql
956
+     */
957
+    public function createParameter($name);
958
+
959
+    /**
960
+     * Creates a new function
961
+     *
962
+     * Attention: Column names inside the call have to be quoted before hand
963
+     *
964
+     * Example:
965
+     * <code>
966
+     *  $qb = $conn->getQueryBuilder();
967
+     *  $qb->select($qb->createFunction('COUNT(*)'))
968
+     *     ->from('users', 'u')
969
+     *  echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u
970
+     * </code>
971
+     * <code>
972
+     *  $qb = $conn->getQueryBuilder();
973
+     *  $qb->select($qb->createFunction('COUNT(`column`)'))
974
+     *     ->from('users', 'u')
975
+     *  echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u
976
+     * </code>
977
+     *
978
+     * @param string $call
979
+     *
980
+     * @return IQueryFunction
981
+     * @since 8.2.0
982
+     *
983
+     * @psalm-taint-sink sql
984
+     */
985
+    public function createFunction($call);
986
+
987
+    /**
988
+     * Used to get the id of the last inserted element
989
+     * @return int
990
+     * @throws \BadMethodCallException When being called before an insert query has been run.
991
+     * @since 9.0.0
992
+     */
993
+    public function getLastInsertId(): int;
994
+
995
+    /**
996
+     * Returns the table name quoted and with database prefix as needed by the implementation
997
+     *
998
+     * @param string $table
999
+     * @return string
1000
+     * @since 9.0.0
1001
+     */
1002
+    public function getTableName($table);
1003
+
1004
+    /**
1005
+     * Returns the column name quoted and with table alias prefix as needed by the implementation
1006
+     *
1007
+     * @param string $column
1008
+     * @param string $tableAlias
1009
+     * @return string
1010
+     * @since 9.0.0
1011
+     */
1012
+    public function getColumnName($column, $tableAlias = '');
1013 1013
 }
Please login to merge, or discard this patch.