I have a request that should, after the expiration of the minute, only perform an update, and it immediately executes ignoring time
$this->db->query(" update colban set `go` = `go` -1 where id = '".(int)$this->url[450]."' < ".( time()-60*1 )); } I have a request that should, after the expiration of the minute, only perform an update, and it immediately executes ignoring time
$this->db->query(" update colban set `go` = `go` -1 where id = '".(int)$this->url[450]."' < ".( time()-60*1 )); } As many have said, you do not need it.
The reason for this question is the lack of understanding of the elementary bases of databases.
That is, in this case, we do not write a specific value to the database at the right time, but write the desired time for changing the value.
And all reading scripts will read this time and compare with the current one. If more, then the value has changed. Very simple, and does not require any crutches from other answers. This is how databases all over the world work.
For example:
sleep(60)curl (with session break) to call a script that will perform the update in a minuteeventssleep() )? - AlexOption 1 - use the mysql SLEEP () function, DO SLEEP(60);
An example mysql query:DO SLEEP(60);UPDATE ...
you can use SELECT SLEEP(60) , but in this case you need to consider that the output will always be 0 or 1.
Option 2 - use the php sleep () function.
Example:SLEEP(60);$this->db->query("...");
Both options delay execution for N seconds.
These functions should not be used if you execute the next request only after receiving the results of the previous one, because, for example, a consecutive call of 2 requests will result in an idle time of 2 * N seconds.
sleep . Thus, it meets the condition of the task должен по истечению минуты только выполнять update . - AlexSource: https://ru.stackoverflow.com/questions/596660/
All Articles