I have the following trigger (generated using PHP via mysqli)…
DROP TRIGGER IF EXISTS post_queue_insert;
CREATE TRIGGER post_queue_insert AFTER INSERT ON posts
FOR EACH ROW BEGIN
IF (NEW.post_type != 'revision' AND NEW.post_status != 'auto-draft') THEN
INSERT INTO event_queue (action_id, action_do, action_key, action_value, action_event, action_timestamp, sync_complete, SITE_ID) VALUES (NEW.ID, 'post', NEW.post_type, NEW.post_status, 'insert', UNIX_TIMESTAMP(now()), 0, 1);
END IF;
END;
What I can't figure out is how to check if the 'post_type' value exists in another table and if it doesn't then insert it.
?
Best Answer
If found_it = 0, then the row does not contain a value matching NEW.post_type.
Give it a Try !!!