|
|
|
@ -150,17 +150,20 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
|
|
|
|
*/ |
|
|
|
|
public function batchInsert($table, $columns, $rows) |
|
|
|
|
{ |
|
|
|
|
foreach ($columns as $i => $name) { |
|
|
|
|
$columns[$i] = $this->db->quoteColumnName($name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$values = array(); |
|
|
|
|
foreach ($rows as $row) { |
|
|
|
|
$vs = array(); |
|
|
|
|
foreach ($row as $value) { |
|
|
|
|
$vs[] = is_string($value) ? $this->db->quoteValue($value) : $value; |
|
|
|
|
} |
|
|
|
|
$values[] = $vs; |
|
|
|
|
$values[] = '(' . implode(', ', $vs) . ')'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 'INSERT INTO ' . $this->db->quoteTableName($table) |
|
|
|
|
. ' (' . implode(', ', $columns) . ') VALUES (' |
|
|
|
|
. implode(', ', $values) . ')'; |
|
|
|
|
. ' (' . implode(', ', $columns) . ') VALUES ' . implode(', ', $values); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|