Dynamic insertion according to date and days of the week

1

I'm creating an application using webservice in PHP. Within the application the user will define specific days to generate an alert, for example:

  • second
  • fourth
  • sixth

In this way, I would like my bank to log an entire event, Monday, Wednesday and Friday successively every week, and show it in the timeline of the user. I do not know if I have to do triggers (do not know if it's possible) in the database or a service in PHP. Can someone clarify me a bit?!

    
asked by anonymous 05.11.2016 / 14:16

1 answer

0

You can create a Event Scheduler in the database. First enable the feature:

SET GLOBAL event_scheduler = ON;

or

SET GLOBAL event_scheduler = 1;

Then create the event. In the following case the event is executed daily and inserts a record in the ALERTA table:

CREATE EVENT novoEvento
ON SCHEDULE EVERY 1 DAY
DO
INSERT INTO alerta(descricao) values('ALERTA');

To show all events:

SHOW EVENTS;

Reference: MySQL - Using the Event Scheduler

    
05.11.2016 / 14:45