A
A
AlexSer2020-01-15 09:34:50
Yii
AlexSer, 2020-01-15 09:34:50

Reasons for double insertion of data in Yii2?

I am inserting data:

public  function actionInsert($id,$barcode){
        if(Yii::$app->request->isAjax){
            if(Yii::$app->request->isGet){
                $id_barcode=Probirki::findOne(['barcode'=>$barcode])->id;
                Yii::$app->db->createCommand()->insert('worklist_probirki', [
                    'id_probirka' => $id_barcode,
                    'id_worklist' =>$id,
                ])->execute();

              return $this->redirect('/laboratory/worklist/spisok?id='.$id);
            }
        }

    }

There is a problem of data duplication. What is the reason?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gip, 2020-01-15
@Giperoglif

Because this code is called twice

I
Ilya Beloborodov, 2020-01-15
@kowap

In the debug panel, see how many times this request is executed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question