Dynamic insertion according to date and days of the week

Asked

Viewed 110 times

1

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

  • second
  • fourth
  • sixth

In this way, I would like my bank to register an entire event, Monday, Wednesday and Friday successively every week, and show in Timeline user. I don’t know if I have to do triggers(do not know if it is possible) in the database or a service in PHP. Someone can clarify me a little?!

1 answer

3

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

SET GLOBAL event_scheduler = ON;

or

SET GLOBAL event_scheduler = 1;

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

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

To show all events:

SHOW EVENTS;

23.4 Using the Event Scheduler

The Mysql Event Scheduler manages the Scheduling and Execution of Events, that is, tasks that run According to a Schedule.

In free translation:

Mysql Event Scheduler manages the scheduling and execution of events, which are, tasks that run according to scheduling.

  • 1

    It seems to be a valid answer. I will try to search a little more about event_scheduler and validate your answer. Abs.

  • 1

    I haven’t taken the test yet, I didn’t get to that part of my project. =)

  • @Viana Managed to test?

  • 3

    @Sorack, by the way you’re very patient, you left two years apart to try again :D

  • 1

    @Bacco hahahaha goes that the project is over and he was just getting ahead...

  • 1

    @Bacco kkkkk I cried

  • @Sorack and it is possible to know which day of the week is with the CREATE EVENT?

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.