Search code examples
phpmysqlsqlmysql-event

Drop Mysql Event as soon as it completes the task


Good day. I was trying to find any documentation but i did not find any and neither an explanation to a situation where i actually need an event to be executed and after the event is execute within the given query statement the event must be dropped.

       $deleteEvent = mysqli_query($connection, "CREATE EVENT deletePareticipants
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
ON COMPLETION PRESERVE
DO 
   BEGIN
      DELETE FROM mafia_room_participants WHERE room_id='$roomId';

      END");

This is the event and i put the ON COMPLETION PRESERVE as the Mysql Documentation stated this

Message: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.

It says immediately after creation...does it mean that mysql event was dropped without actually running the specified query? I just need the query to happen and drop that event as soon as query happened.

Any ideas?


Solution

  • ON COMPLETION PRESERVE

    remove this line