mysql - How does PHP handle the Duplicate entry '' for key 'num' (23000) problem caused by unique indexes?
学习ing
学习ing 2017-07-04 13:43:35
0
3
1078

I have a project that requires interface transmission, which is similar to recharge. I need to receive the order number and put it into the warehouse. There is a variable called a timestamp. Based on this timestamp, I can retrieve the recharge information after this timestamp.
But there is a problem. Yes, in order to prevent missing orders, when I search every 5 minutes, I will increase the timestamp by 28000 instead of 300000. This will cause the order number to be repeated and lead to failure. Thinkphp solves this problem, but it is embarrassing. I use is not a TP framework. Is there any other way to solve this problem?

学习ing
学习ing

reply all(3)
漂亮男人

The key is repeated, which means the empty string inside. What does this have to do with what you said?
It means that the num column has multiple blank strings'' to be inserted into the database.

I didn’t understand your explanation at all.

小葫芦

If you use a unique index, the default value can be set to NULL. NULL values ​​will not conflict, but 0 or empty strings '' will conflict.

黄舟

This error is caused by the database

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template