Answer the question
In order to leave comments, you need to log in
Can a connection break occur when several items are written to the database?
I am working on creating an online store. I suppose that my question concerns the features of the MySQL server.
Essence:
At the time of order formation, 2 manipulations occur:
1. A new order is created in the `orders` table
2. According to the `id` of the newly created order, we write the parameters of the goods of this order into the `order_details` table (product id, quantity, sale price).
Suppose there are 30-40 items in an order. Can it happen that in the process of filling the `order_details` table, a connection break occurs (or some other problem), as a result of which the order composition is not completely saved?
If yes, how can this be avoided? And is it worth it to provide for the "processing" of such situations?
The table engine used is MyISAM.
Answer the question
In order to leave comments, you need to log in
Anything could happen. As a rule, such situations are solved using transactions. But to use them, you should switch from MyISAM to InnoDB . You
can read more about them
here. Specifically, in your case, you should go
Can a connection break occur when several items are written to the database?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question