I am inserting about 1,500 rows of data into a table and there are often duplicate ID’s because the data in the source system has been updated.
What is the most efficient and effective method to perform a batch insert and update records with matching ID?
PS: I tried a foreach loop but got a "run out of memory warning". The batch insert function works well but now I get a duplicate record warning.
Here is my current code:
$insertCount = Yii::$app->db->createCommand() ->batchInsert($tableName, $columnNameArray, $data) ->execute();