0

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?

Sasha
  • 8,521
  • 23
  • 91
  • 174

1 Answers1

1

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

Community
  • 1
  • 1
Sasha Pachev
  • 5,162
  • 3
  • 20
  • 20