For created_at timestamp
CREATE TRIGGER `Update create at Timestamp If New Insert`
AFTER INSERT ON `table_name`
FOR EACH ROW
UPDATE `table_name` SET `created_on` = UNIX_TIMESTAMP()
WHERE id = NEW.id
For Update timestamp
CREATE TRIGGER `Update update at timestamp on update`
AFTER UPDATE ON `table_name`
FOR EACH ROW
UPDATE `table_name` SET `updated_at` = UNIX_TIMESTAMP() WHERE id = NEW.id
CREATE TRIGGER `Update create at Timestamp If New Insert`
AFTER INSERT ON `table_name`
FOR EACH ROW
UPDATE `table_name` SET `created_on` = UNIX_TIMESTAMP()
WHERE id = NEW.id
For Update timestamp
CREATE TRIGGER `Update update at timestamp on update`
AFTER UPDATE ON `table_name`
FOR EACH ROW
UPDATE `table_name` SET `updated_at` = UNIX_TIMESTAMP() WHERE id = NEW.id
0 comments:
Post a Comment