CodeIgniter Forums
Community Auth - no grant for TRIGGER - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: Community Auth - no grant for TRIGGER (/showthread.php?tid=67349)



Community Auth - no grant for TRIGGER - galisedotes - 02-13-2017

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 ;


RE: Community Auth - no grant for TRIGGER - skunkbad - 02-13-2017

(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.