I've got 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 problem is that when there are more than 10 users online, there is big chance that 2 users click at same time = attack is proccessing twice. However, I do not want to increase query count to have "column" for example "locked". Does anybody know solution ?
What I think is...
Instead of just storing 0000-00-00 00:00:00, i think you can store-in more precisely datetime, like 0000-00-00 00:00:00.00000 (miliseconds). The chances of concurrent action will decrease much.
So if you compare to $current_time, the $current_time has to be in 0000-00-00 00:00:00.00000 format too
here is the way how to get the time with miliseconds
Note: you can change date("Y-m-d\TH:i:s") to date("Y-m-d H:i:s") if you don't want the 'T'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With