M
M
Maxim Osadchy2018-02-06 17:40:50
Yii
Maxim Osadchy, 2018-02-06 17:40:50

How to delete a record from the database by timer?

Hello!
Let's assume there is an entry in the database and a column in which the date of deletion of this entry is marked.
How to implement it? If possible - in two versions, in yii2 and pure php, at least at the level of the action algorithm.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Konkin, 2018-02-06
@waspmax1

By Cron'u check the date of deletion - if the time has come, then delete. Cron script can be in yii or pure php.

O
Oleg, 2018-02-07
@402d

delete operation is expensive.
cron might not work.
does not run more than 1 time per minute.
it's easier to have an expired
select * from where id=? and expired is less than now()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question