A
A
AR2019-01-11 16:35:18
MySQL
AR, 2019-01-11 16:35:18

Another error appears General error: 1205 Lock wait timeout exceeded; try restarting transaction?

Why does the above error appear when trying to papdate objects in the Products model? ($model and $modelObject are not Products objects) ??

$transaction = \Yii::$app->db->beginTransaction();
            try {
                $model->save();
                foreach (Yii::$app->request->post('Line') as $t) {
                    $modelObject = new RevenueItems();
                    $modelObject->attributes = [
                        АТТРИБУТЫ
                    ];
                    $modelObject->save();
                    Products::updateAll(['quantity' => $newQuantity ], ['id' => АЙДИ_ПРОДУКТА]);
                }
                $transaction->commit();
            } catch (\Exception $e) {
                $transaction->rollBack();
                throw $e;
            }

That is, without the line:
Products::updateAll(['quantity' => $newQuantity ], ['id' => АЙДИ_ПРОДУКТА]);

Everything works as it should. What could be the problem ?
Thanks in advance

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question