Completed
Push — 3.x ( e5eb1c...76cecd )
by Paul
9s
created

InsertBuilder::buildInto()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace Aura\SqlQuery\Common;
3
4
class InsertBuilder extends AbstractBuilder
5
{
6
7
    /**
8
     *
9
     * Builds the INTO clause.
10
     *
11
     * @return string
12
     *
13
     */
14 42
    public function buildInto($into)
15
    {
16 42
        return " INTO {$into}";
17
    }
18
19
20
    /**
21
     *
22
     * Builds the inserted columns and values of the statement.
23
     *
24
     * @return string
25
     *
26
     */
27 22
    public function buildValuesForInsert($col_values)
28
    {
29
        return ' ('
30 22
            . $this->indentCsv(array_keys($col_values))
31 22
            . PHP_EOL . ') VALUES ('
32 22
            . $this->indentCsv(array_values($col_values))
33 22
            . PHP_EOL . ')';
34
    }
35
36
    /**
37
     *
38
     * Builds the bulk-inserted columns and values of the statement.
39
     *
40
     * @return string
41
     *
42
     */
43 20
    public function buildValuesForBulkInsert($col_order, $col_values_bulk)
44
    {
45 20
        $cols = "    (" . implode(', ', $col_order) . ")";
46 20
        $vals = array();
47 20
        foreach ($col_values_bulk as $row_values) {
48 20
            $vals[] = "    (" . implode(', ', $row_values) . ")";
49
        }
50 20
        return PHP_EOL . $cols . PHP_EOL
51 20
            . "VALUES" . PHP_EOL
52 20
            . implode("," . PHP_EOL, $vals);
53
    }
54
}
55