Updating Mysql Table at a Certain Time

Asked

Viewed 163 times

1

Good afternoon,

My question is the following, I have locks in my application in PHP with Codeingniter, and I need to release users a few times. So, I select my user for 2(Supervisor) but I want that the next day, at 8 am it returns to 1(user).

I tried to make m JS with setTimeout, but for the application to work I would have it on the page... I wanted to do it dynamically, I read about Mysql event, but I was not a bit confused with its functioning.

If anyone can help me, I’d be very grateful!

  • because it does not create a script in runs with cronjob?

  • How would that be ?

  • 2

    "I tried to do m JS with setTimeout" you want to update something on the server using a client event in the browser? that doesn’t make sense, apart from whether the browser should continue open. Why don’t you use CREATE EVENT and creates an event in the database to do this?

  • @Ricardopunctual other doubt, just doing the CREAT EVENT and putting as EVERY 8 DAY_HOUR, it will run every day at this same time? Or I need to do something else?

  • after creating the event the "Mysql Event Scheduler" is responsible for executing according to the Schedule that was scheduled, so being working will always trigger the event at that time every day.

  • I guess my plan at Hostgator doesn’t do that...

  • 1

    you must consult them to confirm, but if you are running the bank service you must have the event service, you need to see if it is shared and how to configure

  • Managed using cron scheduling service

Show 3 more comments

1 answer

2


It’s clear like this ??

CREATE EVENT nome_do_evento
        ON SCHEDULE
          EVERY 8 DAY_HOUR
         COMMENT 'faz algo as  8:00 am todos os dias'
        DO
          UPDATE tabela SET coluna = valor ...
  • 1

    Can I merge this with a Trigger? To just run this function if I’ve made a modification to the table ?

  • And I need the function to run only when I modify the user.

  • 1

    This way it is written, where there is table I need to put "db name.table" ?

  • Can you do it? and if you want to make a Rigger you should declare "name db.table", but try not to ask more questions in comments but create a new question, as it is advised not to answer with comments ;) and everyone is winning

Browser other questions tagged

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