Welcome Guest, Not a member yet? Register   Sign In
Community Auth - no grant for TRIGGER
#1

Attempting to set up an application that can be used on any standard web hosting system. Most don't allow TRIGGER as a grant access to mysql. Is there a work around for this statement?

delimiter $$
DROP TRIGGER IF EXISTS ca_passwd_trigger ;
$$
CREATE TRIGGER ca_passwd_trigger BEFORE UPDATE ON users
FOR EACH ROW
BEGIN
    IF ((NEW.passwd <=> OLD.passwd) = 0) THEN
        SET NEW.passwd_modified_at = NOW();
    END IF;
END;$$
delimiter ;
Reply
#2

(This post was last modified: 02-13-2017, 04:19 PM by skunkbad.)

(02-13-2017, 06:05 AM)galisedotes Wrote: Attempting to set up an application that can be used on any standard web hosting system. Most don't allow TRIGGER as a grant access to mysql. Is there a work around for this statement?

delimiter $$
DROP TRIGGER IF EXISTS ca_passwd_trigger ;
$$
CREATE TRIGGER ca_passwd_trigger BEFORE UPDATE ON users
FOR EACH ROW
BEGIN
    IF ((NEW.passwd <=> OLD.passwd) = 0) THEN
        SET NEW.passwd_modified_at = NOW();
    END IF;
END;$$
delimiter ;


The `passwd_modified` field is not actually used, but is only triggered to update so that a dev can do something with that date value. So just don't try to create the trigger, and all is well.

If you need a true workaround because you intend to use the passwd_modified field, then anytime you update a user's password you would just update the passwd_modified field at the same time.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB