What is wrong with the update query?

yii2, can't do multiple update (need to update ~10K records).
the query looks like this:
UPDATE `product`
SET `name`=(
CASE
 WHEN `code`=122 THEN "product_name1"
/*...*/
 WHEN `code`=125 THEN "product_nameN"
END)
WHERE `code` IN (122,125,/*...*/, 999999);

php code:
$sql = "
 . 'UPDATE {{' . Products::tableName() . '}}'
 . 'SET [[name]]=(CASE';
foreach ($name_update_array as $record_code => $record_name) {
 $sql .= 'WHEN [[code]]=' . $record_code . 'THEN "' . $record_name . '"';
}
$sql .= 'END') WHERE [[code]] IN (' . implode(',', array_keys($name_update_array)) . ')';
$query = \Yii::$app->db->createCommand($sql);
try {
$query->execute();
}
catch (\Exception $exception) {
Log::addLog([
 'logfile' => $this->logfile,
 'name' => $settings['name'],
 'status' => 'ERROR',
 'data' => $exception
]);
 return false;
}


error:
Next yii\db\Exception: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound

when manually entering and for small quantities of records all perfectly fulfills.
UPDATE product SET name=(CASE WHEN code=121 THEN "qwe" WHEN code=122 THEN "qweasd" END) WHERE code IN (121,122,125,126,127);
Query OK, 5 rows affected, 3 warnings (0.03 sec)
Rows matched: 5 Changed: 5 Warnings: 3

how to fix?
March 23rd 20 at 19:19
1 answer
March 23rd 20 at 19:21
Solution
disagree.
transferred the curve to json, where was the name with quotes, and trying to make a request went something like this:
...name="product name"product name" weight 500 kg"...
fixed like this:
$sql .= 'WHEN [[code]]=' . $record_code . 'THEN \" . $record_name . '\";

Find more questions by tags Yii