Completed
Branch feature/pre-split (9d6b17)
by Anton
03:28
created

UpdateCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
namespace Spiral\ORM\Commands;
8
9
use Spiral\Database\Entities\Table;
10
11
class UpdateCommand extends TableCommand
12
{
13
    /**
14
     * Where conditions (short where format).
15
     *
16
     * @var array
17
     */
18
    private $where = [];
19
20
    /**
21
     * Columns to be updated.
22
     *
23
     * @var array
24
     */
25
    private $values = [];
26
27
    /**
28
     * UpdateCommand constructor.
29
     *
30
     * @param Table $table
31
     * @param array $where
32
     * @param array $values
33
     */
34
    public function __construct(Table $table, array $where, array $values)
35
    {
36
        parent::__construct($table);
37
        $this->where = $where;
38
        $this->values = $values;
39
    }
40
41
    /**
42
     * @param array $where
43
     */
44
    public function setWhere(array $where)
45
    {
46
        $this->where = $where;
47
    }
48
49
    /**
50
     * Inserting data into associated table.
51
     */
52
    public function execute()
53
    {
54
        $this->table->update($this->values, $this->where)->run();
55
        parent::execute();
56
    }
57
}