Passed
Push — master ( b2168e...f1daef )
by Paweł
03:26
created

BatchInsertCommand::batchInsertIgnoreCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created for IG Monitoring.
4
 * User: jakim <[email protected]>
5
 * Date: 2019-02-12
6
 */
7
8
namespace app\components\traits;
9
10
11
12
trait BatchInsertCommand
13
{
14
    /**
15
     * @param string $table
16
     * @param array $columns
17
     * @param array $rows
18
     * @return \yii\db\Command
19
     */
20
    public function batchInsertIgnoreCommand(string $table, array $columns, array $rows)
21
    {
22
        $sql = \Yii::$app->db->queryBuilder
23
            ->batchInsert($table, $columns, $rows);
24
        $sql = str_replace('INSERT INTO ', 'INSERT IGNORE INTO ', $sql);
25
26
        return \Yii::$app->db->createCommand($sql);
27
    }
28
}