Delete registration 24hrs after created

0

As I do so that the records of a table in my MySql database are deleted every 24 hours automatically without using cronjobs.

Pd: use php.

Greetings.

    
asked by ByGroxD 21.02.2017 в 22:40
source

1 answer

2

If you have administrator access to your MySQL and you can enable the event scheduler , then you can schedule periodic events of the form:

CREATE EVENT limpieza
    ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
    DO
      TRUNCATE TABLE esquema.tabla;

Or

CREATE EVENT limpieza
    ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
    DO
      DELETE FROM esquema.tabla WHERE creacion < (CURRENT_TIMESTAMP - INTERVAL 1 DAY);

It's still a kind of cronjob, but at least it runs internally.

    
answered by 21.02.2017 / 22:54
source