Sqlite::obtainPartsToDisable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BfwSql\Queries\SGBD;
4
5
class Sqlite extends AbstractSGBD
6
{
7
    /**
8
     * {@inheritdoc}
9
     * 
10
     * Disable all joins for update queries with sqlite
11
     */
12
    protected function obtainPartsToDisable(): array
13
    {
14
        return [
15
            'delete' => [],
16
            'insert' => [],
17
            'select' => [],
18
            'update' => ['join', 'joinLeft', 'joinRight']
19
        ];
20
    }
21
    
22
    /**
23
     * {@inheritdoc}
24
     * 
25
     * Not add table name/shortcut before column name for an update query.
26
     */
27
    public function columnName(
28
        string $colName,
29
        string $tableName,
30
        bool $isFunction,
31
        bool $isJoker
32
    ): string {
33
        if ($this->obtainRequestType() === 'update') {
34
            if ($isFunction === true || $isJoker === true) {
35
                return $colName;
36
            } else {
37
                return '`'.$colName.'`';
38
            }
39
        }
40
        
41
        return parent::columnName($colName, $tableName, $isFunction, $isJoker);
42
    }
43
}
44