0
votes

I am using this code for inserting batch:

$db  = Yii::$app->db;
$sql = $db->queryBuilder->batchInsert('components', ["name"], $components);
$db->createCommand($sql . ' ON DUPLICATE KEY UPDATE')->execute();

And I am getting this error: SQLSTATE[42000]: Syntax error or access violation: 1064. What seems to be the problem?

1

1 Answers

1
votes

You need to be more specific in the ON DUPLICATE KEY UPDATE syntax at the end of the query. See examples at On Duplicate Key Update same as insert