summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/sql/src/WhereInterface.php
blob: e72446504777a43feeadb354feb9db6da569670c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php

namespace ipl\Sql;

/**
 * Interface for the WHERE part of a query
 */
interface WhereInterface
{
    /**
     * Get the WHERE part of the query
     *
     * @return array|null
     */
    public function getWhere();

    /**
     * Add a WHERE part of the query
     *
     * This method lets you specify the WHERE part of the query using one of the two following supported formats:
     * * String format, e.g. 'id = 1', i.e. `where(string $condition [, mixed ...$args])`
     * * Array format, e.g. ['id = ?' => 1, ...], i.e. `where(array $condition [, string $operator])`
     *
     * This method does NOT quote the columns you specify for the WHERE.
     * If you allow user input here, you must protected yourself against SQL injection using
     * {@link Connection::quoteIdentifier()} for the field names passed to this method.
     * If you are using special field names, e.g. reserved keywords for your DBMS, you are required to use
     * {@link Connection::quoteIdentifier()} as well.
     *
     * Note that this method does not override an already set WHERE part. Instead, multiple calls to this function add
     * the specified WHERE part using the AND operator.
     *
     * @param string|ExpressionInterface|Select|array $condition The WHERE condition
     * @param mixed $args If condition is a string, parameter values for placeholders in the condition can be passed.
     *                    If condition is an array, the only argument that is allowed is the operator to use to combine
     *                    these conditions. By default, this operator is {@link Sql::ALL} (AND)
     *
     * @return $this
     */
    public function where($condition, ...$args);

    /**
     * Add a OR part to the WHERE part of the query
     *
     * Please see {@link where()} for the supported formats and restrictions regarding quoting of the field names.
     *
     * @param string|ExpressionInterface|Select|array $condition The WHERE condition
     * @param mixed                                   ...$args   Please see {@link where()} for details
     *
     * @return $this
     */
    public function orWhere($condition, ...$args);

    /**
     * Add a AND NOT part to the WHERE part of the query
     *
     * Please see {@link where()} for the supported formats and restrictions regarding quoting of the field names.
     *
     * @param string|ExpressionInterface|Select|array $condition The WHERE condition
     * @param mixed                                   ...$args   Please see {@link where()} for details
     *
     * @return $this
     */
    public function notWhere($condition, ...$args);

    /**
     * Add a OR NOT part to the WHERE part of the query
     *
     * Please see {@link where()} for the supported formats and restrictions regarding quoting of the field names.
     *
     * @param string|ExpressionInterface|Select|array $condition The WHERE condition
     * @param mixed                                   ...$args   Please see {@link where()} for details
     *
     * @return $this
     */
    public function orNotWhere($condition, ...$args);

    /**
     * Reset the WHERE part of the query
     *
     * @return $this
     */
    public function resetWhere();
}