Answer the question
In order to leave comments, you need to log in
Is it possible to temporarily write to the database without using cron?
Hello. Now the following question has arisen:
Is it possible somehow at the PHP or jquery level (I can’t even imagine how to implement it) to temporarily add or update a row in the database?
Those. for example, there is a products table , it has a row with an ID column of 3 , that row has an "action" column. In the engine (php, smarty) I change this value from 0 to 1 and vice versa. The question is this: is it possible to somehow set the action column to 1 for a certain period, for example, 2 hours, without using cron?
Answer the question
In order to leave comments, you need to log in
You can store a UNIX time stamp in the field. And at sampling from db to consider this value.
Where :uts = time() - 7200, those same 2 hours.
Then you can do without CRON and the MySQL scheduler, but you will have to pay for an additional int field in the table.
Or you can add another table that will have 2 fields: product id and UNIX time stamp. Then you will need to add JOIN to the query.
SELECT p.* FROM products as p
LEFT JOIN rel_table as rt
ON rt.id = p.id
WHERE rt.uts IS NOT NULL AND rt.uts < :uts
MySQL has a built-in scheduler, but it needs to be enabled in the config
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question