Skip to content

Commit

Permalink
Improve performance of quoting column names up to 10% using `array_ma…
Browse files Browse the repository at this point in the history
…p()`
  • Loading branch information
Tigrov committed Oct 4, 2023
1 parent c692a58 commit 7c7fc03
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/DMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder;

use function array_map;
use function implode;
use function count;

Expand Down Expand Up @@ -67,9 +68,10 @@ public function batchInsert(string $table, array $columns, iterable|Generator $r
return '';
}

foreach ($columns as $i => $name) {
$columns[$i] = $this->quoter->quoteColumnName($name);
}
$columns = array_map(
[$this->quoter, 'quoteColumnName'],
$columns,
);

$tableAndColumns = ' INTO ' . $this->quoter->quoteTableName($table)
. ' (' . implode(', ', $columns) . ') VALUES ';
Expand Down

0 comments on commit 7c7fc03

Please sign in to comment.