summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/sql/src/Expression.php
blob: 83c10bda4ec15934bdb0bc3bab02f82d48568178 (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
<?php

namespace ipl\Sql;

/**
 * A database expression that does need quoting or escaping, e.g. new Expression('NOW()');
 */
class Expression implements ExpressionInterface
{
    /** @var string The statement of the expression */
    protected $statement;

    /** @var array The columns used by the expression */
    protected $columns;

    /** @var array The values for the expression */
    protected $values;

    /**
     * Create a new database expression
     *
     * @param string $statement The statement of the expression
     * @param array $columns The columns used by the expression
     * @param mixed  ...$values The values for the expression
     */
    public function __construct($statement, array $columns = null, ...$values)
    {
        $this->statement = $statement;
        $this->columns = $columns;
        $this->values = $values;
    }

    public function getStatement()
    {
        return $this->statement;
    }

    public function getColumns()
    {
        return $this->columns ?: [];
    }

    public function setColumns(array $columns)
    {
        $this->columns = $columns;

        return $this;
    }

    public function getValues()
    {
        return $this->values;
    }
}