在某些时候清空数据库表

时间:2022-09-15 16:29:39

I have a database table that I need to empty every 24 hours, or whatever time that I set it to. I don't want the table deleted, just emptied. I'm wondering what the best method would be to do this using PHP? Really appreciate any direction you can provide for me.

我有一个数据库表,我需要每24小时清空一次,或者我设置它的任何时间。我不想删除表,只是清空。我想知道用PHP做这个最好的方法是什么?非常感谢您为我提供的任何指导。

1 个解决方案

#1


1  

You can do this using Event Scheduler.

您可以使用Event Scheduler执行此操作。

Query can be something like this:

查询可以是这样的:

DELETE FROM your_table WHERE time < NOW() - INTERVAL 24 HOUR

#1


1  

You can do this using Event Scheduler.

您可以使用Event Scheduler执行此操作。

Query can be something like this:

查询可以是这样的:

DELETE FROM your_table WHERE time < NOW() - INTERVAL 24 HOUR