Skip to content

Instantly share code, notes, and snippets.

@EstebanFuentealba
Last active August 29, 2015 14:08
Show Gist options
  • Save EstebanFuentealba/b9e442465f0eb5eca483 to your computer and use it in GitHub Desktop.
Save EstebanFuentealba/b9e442465f0eb5eca483 to your computer and use it in GitHub Desktop.
--
-- Disparador para borrar shtml
--
DROP TRIGGER IF EXISTS `beforeUpdatePostshtml`;
DELIMITER //
CREATE TRIGGER beforeUpdatePostshtml BEFORE UPDATE ON wp_posts FOR EACH ROW BEGIN
IF OLD.post_name != NEW.post_name
AND OLD.post_name != ''
AND NEW.post_type = 'post'
AND NEW.post_status = 'publish'
THEN
INSERT INTO delete_shtml(post_id, post_shtml) VALUES(NEW.ID, CONCAT('/', DATE_FORMAT(OLD.post_date,'%Y/%m/%d/'),OLD.post_name,'.shtml'));
END IF;
END
//
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment