SqliteQueryBuilder::getQueryHead()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 4
nop 0
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the DbImporter package.
4
 *
5
 * (c) Mauro Cassani<https://github.com/mauretto78>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace DbImporter\QueryBuilder;
12
13
class SqliteQueryBuilder extends AbstractQueryBuilder
14
{
15
    const MULTIPLE_QUERY_IMPORT_LIMIT = 100;
16
17
    /**
18
     * @return string
19
     */
20
    private function getQueryHead()
21
    {
22
        $sql = 'INSERT ';
23
24
        if (true === $this->debug) {
25
            $sql .= 'OR IGNORE ';
26
        }
27
28
        $sql .= 'INTO `'.$this->table.'` (';
29
        $c = 1;
30
        $values = array_keys($this->mapping);
31
32
        foreach ($values as $value) {
33
            $sql .= '`'.$value.'`';
34
            $sql .= $this->appendComma($c, $values);
35
            $c++;
36
        }
37
38
        $sql .= ') VALUES ';
39
40
        return $sql;
41
    }
42
43
    /**
44
     * Returns the array of insert queries
45
     * @param string $mode
46
     *
47
     * @return array
48
     */
49
    public function getQueries($mode = 'multiple')
50
    {
51
        $sql = [];
52
53
        foreach ($this->getQueriesBody($mode, self::MULTIPLE_QUERY_IMPORT_LIMIT) as $query) {
54
            $sql[] = $this->getQueryHead().$query;
55
        }
56
57
        return $sql;
58
    }
59
}
60