Because there are a lot of database fields, I'll make an analogy.
Details table List
Users table user has a field num
I execute a method that inserts a single piece of data into a list at the same time to the num+1 of the user table
There were about 20W registered users last month, and I got the numbers from these users ' list tables separately, and compared them to num in the user table.
The comparison is about 70 people's list data, which is about 10 less than the number recorded by Num.
Because the methods are executed successively, presumably in the order of precedence
Public Function test () {
Insert $data;
Update num+1;
}
Insert in list first, update the User num field
I'd like to ask what happens when this data is out of sync. Please do not let the sticker code.
Reply to discussion (solution)
You're supposed to use the business.
Undo operation when insert $data or update num+1 fails
Did you use transaction processing? Determine if insert is successful before updating field
Insert $data; Failed but still executed update num+1; it will be inconsistent.
Did you use transaction processing? Determine if insert is successful before updating field
Insert $data; Failed but still executed update num+1; it will be inconsistent.
Eldest brother, generally under what circumstances will fail, feel no situation ah, is an INSERT statement, the user name is the mobile phone number. Fields can also be empty
Duplicate phone number, write value and field type inconsistency may fail
You should filter user data before you write to the database
Duplicate phone number, write value and field type inconsistency may fail
You should filter user data before you write to the database
Definitely filtered, that day wrote a monitoring, the results to now no problem, and so on to know what the situation, thanks buddies.