Process an action twice - how to prevent it?

I have a problem. I have my own browser game, and there is something like

SELECT * FROM attack WHERE proc = 0 AND endtime < $current_time

it works, but the problem is that when there are more than 10 users on the Internet, there is a high probability that 2 users click at the same time = the attack is performed twice. However, I do not want to increase the number of queries in order to have a “column”, for example, “locked”. Does anyone know a solution?

+3
source share
1 answer

What I think...

Instead of just storing 0000-00-00 00:00:00, I think you can store more accurately during the day, like 0000-00-00 00: 00: 00.00000 (miliseconds). The chances of simultaneous action will decrease significantly.

, $current_time, $current_time 0000-00-00 00: 00: 00.00000.

- miliseconds

: ( "Y-m-d\TH: i: s" ) ( "Y-m-d H: i: s" ), "T"

+4

All Articles