How can I give limited time to events in a Mysql and PHP table?

0

Good afternoon everyone apologize for my little annoyance.

I have a little doubt, I'm trying to give time to each event that enters the db Event table in the duration column, what I want to do is count down to "0" and then delete all the row of the table automatically.

My table is something like this:

Table "Event"

id    nombre       datalles   fecha       duracion
1     ticket_Rock  Solo rock  16/02/2018  24h
2     ticket_otros Solo otros 18/02/2018  48h

CURRENT_TIMESTAMP is used in the column "duration" is there I think I'm fine ... I would appreciate very much for your help.

    
asked by Alex 16.02.2018 в 21:36
source

1 answer

0

I think you're giving the wrong approach, usually what you do is not have a value in the database that has to be mutating to a new one as time goes by, what you do is put an end date for example with the date when the validity of the registration is lost.

So you can:

  • Check by that date to not show the records.
  • use some type of cronjob or process that erases all events outside of that date.

MySql gives you some functions to calculate dates and add times.

link

Greetings

    
answered by 29.03.2018 в 12:14