There is an hour row in the users table, the default value is 0.
After the function is executed, the hour value becomes 1
How to make it so that, 4 hours after the value became 1, it again changed to 0?
As I understand you want to make it so that the user can perform a function once every 4 hours, you can do this: After performing the function, we record (the current time + the time interval we need (in this case, 60 * 60 * 4 seconds) time() + 14400 to the database and when we try to call this function we compare the time to time , if the current time is less than the time in the table, then we refuse to execute.
now() + interval 4 hour instead of time () + 14400, in addition, MySQL will make it much more efficient than php - MikeSource: https://ru.stackoverflow.com/questions/949793/
All Articles
hour < now()-interval 4 hour- Mike