项目

一般

简介

支持 #839

张 丽丽 更新于 6 个月 之前

*RoleId =7是 用户; RoleId=8是 站长* 

 
 update_notify 

 


 <pre> 
 BEGIN 
		 DECLARE newUserName varchar(190); 
		 SELECT UserName INTO newUserName FROM userprofile WHERE UserId = NEW.UserId; 
		
		 IF OLD.RoleId=8 THEN 
			 DELETE FROM `表_站长` WHERE ID=OLD.UserId; 
		 end IF; 
		 IF NEW.RoleId=7 THEN 
     INSERT INTO `表_用户` (ID,`用户_用户名`) VALUES (NEW.UserId,newUserName); 
		 end IF; 
		
		 IF OLD.RoleId=7 THEN 
			 DELETE FROM `表_用户` WHERE ID=OLD.UserId; 
		 end IF; 
		 IF NEW.RoleId=8 THEN 
     INSERT INTO `表_站长` (ID,`站长_用户名`) VALUES (NEW.UserId,newUserName); 
		 end IF; 
 end 
 </pre> 

 delete_notify 
 <pre> 
 BEGIN 
		 IF OLD.RoleId=7 THEN 
			 DELETE FROM `表_用户` WHERE ID=OLD.UserId; 
		 end IF; 
		 IF OLD.RoleId=8 THEN 
			 DELETE FROM `表_站长` WHERE ID=OLD.UserId; 
		 end IF; 
 end 
 </pre> 

 insert_notify 
 <pre> 
 BEGIN 
 DECLARE tmp varchar(190); 
     SELECT UserName INTO tmp FROM userprofile WHERE UserId = NEW.UserId; 
		 IF NEW.RoleId=7 THEN 
     INSERT INTO `表_用户` (ID,`用户_用户名`) VALUES (NEW.UserId,tmp); 
		 end IF; 
		 IF NEW.RoleId=8 THEN 
     INSERT INTO `表_站长` (ID,`站长_用户名`) VALUES (NEW.UserId,tmp); 
		 end IF; 
 end 
 </pre> 



返回