From 683f42ae274cc55dd6dec1ba04d28bde342f5aa2 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 8 Jun 2016 08:57:45 +0200 Subject: [PATCH] IntegrityException error importing rows with same pk This fix allows to update the previous imported row with the new one (of course by pk) oherwise it throws \yii\db\IntegrityException --- src/import/basic/Importer.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/import/basic/Importer.php b/src/import/basic/Importer.php index cd7ecbc..e0be552 100644 --- a/src/import/basic/Importer.php +++ b/src/import/basic/Importer.php @@ -44,14 +44,10 @@ protected function safeRun() $this->fillModels($this->_phpExcel->getActiveSheet()->getRowIterator()); - foreach ($this->_models as $model) { - $model->load(); - $model->validate(); - } - Yii::$app->db->transaction(function () { foreach ($this->_models as $model) { - $model->save(false); + $model->load(); + $model->save(); } });