-- ---------------------------- -- eb_system_menus 触发器编写 -- 新增、修改、删除 -- 自动执行 eb_seller_menus -- ---------------------------- -- delimiter $ -- create trigger auto_insert_sellerMenus after insert on eb_system_menus -- for each row -- BEGIN -- declare c varchar(110); -- declare cc varchar(120); -- set c = replace(new.menu_path,'/admin/','/seller/'); -- set cc = replace(new.module,'admin','seller'); -- INSERT into eb_seller_menus (pid,icon,menu_name,module,controller,action,api_url,methods,params,sort,is_show,is_show_path -- ,access,menu_path,path,auth_type,header,is_header,unique_auth,is_del) -- values -- (new.pid,new.icon,new.menu_name,cc,new.controller,new.action,new.api_url,new.methods,new.params,new.sort,new.is_show,new.is_show_path -- ,new.access,c,new.path,new.auth_type,new.header,new.is_header,new.unique_auth,new.is_del); -- END$ -- delimiter $ -- create trigger auto_update_sellerMenus after UPDATE on eb_system_menus -- for each row -- begin -- declare c varchar(110); -- declare cc varchar(120); -- set c = replace(new.menu_path,'/admin/','/seller/'); -- set cc = replace(new.module,'admin','seller'); -- UPDATE eb_seller_menus set pid=new.pid,icon=new.icon,menu_name=new.menu_name,module=cc,controller=new.controller,action=new.action,api_url=new.api_url, -- methods=new.methods,params=new.params,sort=new.sort,is_show=new.is_show,is_show_path=new.is_show_path,access=new.access,menu_path=c,path=new.path, -- auth_type=new.auth_type,header=new.header,is_header=new.is_header,unique_auth=new.unique_auth,is_del=new.is_del where id=old.id; -- END$ DELIMITER $ CREATE TRIGGER auto_delete_sellerMenus after DELETE on eb_system_menus for each row DELETE from eb_seller_menus where id=old.id;
mysql中触发器
在新增数据的触发器中,如何获取新增的列数据,修改新增列数据后 在写入新的数据表中呀。
例如 表A 一条新增数据的user列的数据为ab,通过触发器后新表B的 user列的数据为fdab
具体实现可以参考以上代码的实现
标签:触发器,show,--,menu,mysql,auth,path,增删,new From: https://www.cnblogs.com/woaijingjing/p/16902639.html