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

InsertBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 24
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildValuesForUpdateOnDuplicateKey() 0 14 3
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\SqlQuery\Mysql;
10
11
use Aura\SqlQuery\Common;
12
13
class InsertBuilder extends Common\InsertBuilder
14
{
15
    /**
16
     *
17
     * Builds the UPDATE ON DUPLICATE KEY part of the statement.
18
     *
19
     * @return string
20
     *
21
     */
22 12
    public function buildValuesForUpdateOnDuplicateKey($col_on_update_values)
23
    {
24 12
        if (empty($col_on_update_values)) {
25 11
            return ''; // not applicable
26
        }
27
28 1
        $values = array();
29 1
        foreach ($col_on_update_values as $key => $row) {
30 1
            $values[] = $this->indent(array($key . ' = ' . $row));
31
        }
32
33
        return ' ON DUPLICATE KEY UPDATE'
34 1
            . implode (',', $values);
35
    }
36
}
37