Time trigger u MySQL-u?

Pozdrav svima, zanima me dali je moguće i kako da baza automatski promijeni u mom slučaju active u ‘0’ kada prođe određeni datum (date_time) ? Ili se to radi preko npr. php-a?

+-------------------+--------------+------+-----+---------+----------------+
| Field             | Type         | Null | Key | Default | Extra          |
+-------------------+--------------+------+-----+---------+----------------+
| date_activated    | datetime      | YES  |      | NULL    |                |
| date_end           | datetime      | YES  |     | NULL    |                |
| active               | tinyint(1)      | NO   |     | NULL    |                |
+-------------------+--------------+------+-----+---------+----------------+

MySQL :: MySQL 5.1 Reference Manual :: 19.4 Using the Event Scheduler

neki primjer na netu??
nisam uspio naći

CREATE EVENT e_daily
    ON SCHEDULE
      EVERY 1 DAY
    COMMENT 'Upadate active field'
    DO
      UPDATE table1
            SET active = 1
            WHERE date_end < CURDATE()

Ovo je onako od oka, jer nemam pojma što točno trebaš. Mislim da ti može poslužiti kao primjer.
Osim toga evo manual: MySQL :: MySQL 5.1 Reference Manual :: 13.1.11 CREATE EVENT Syntax

RTFM pobogu, tamo piše sve.

Otkrio sam, ALI prvo sam morao konfigurati MySQL tj. uplait ‘event scheduler’

aham,

[php]
DELIMITER $$
CREATE EVENT update_active ON SCHEDULE EVERY 1 MINUTE STARTS ‘[DATE]’ ON COMPLETION PRESERVE ENABLE DO BEGIN
UPDATE users
SET active = 0
WHERE date_end < NOW() AND active = 1;
END$$

[/php]


Copyright © 2022 WM Forum - AboutContact