ecshop中自定义mysql函数处理

2014-07-28 12:54 来源:www.chinab4c.com 作者:ecshop专家

?? ecshop中自定义mysql函数处理

??
首先开启自定义函数开关
SET GLOBAL log_bin_trust_function_creators = 1

?SET GLOBAL log_bin_trust_function_creators = 1

CREATE? FUNCTION `concat_ic`(goods_name varchar(64)) RETURNS varchar(64) CHARSET utf8

BEGIN
DECLARE temp varchar(64);
set temp =? replace(goods_name,"#","");
set temp =? replace(temp,".","");
set temp = ??? replace(temp,"/","");
set temp = ??? replace(temp,"-","");
set temp = ??? replace(temp,"=","");
set temp = ??? replace(temp,"_","");
set temp = ??? replace(temp," ","");
set temp = ??? replace(temp,"+","");
set temp = ??? replace(temp,"(","");
set temp = ??? replace(temp,")","");
set temp = ??? replace(temp,"!","");
set temp = ??? replace(temp,"\"","");
set temp = ??? replace(temp,"$","");
set temp = ??? replace(temp,"%","");
set temp = ??? replace(temp,"&","");
set temp = ??? replace(temp,"'","");
set temp = ??? replace(temp,"*","");
set temp = ??? replace(temp,",","");
set temp = ??? replace(temp,":","");
set temp = ??? replace(temp,";","");
set temp = ??? replace(temp,"<","");
set temp = ??? replace(temp,"\|","");
set temp =????? concat("€€",temp);
set temp =????? concat(goods_name,temp);
return temp;
end
?

?我们在检索ecshop商品的时候,select goods_id,concat_ic(goods_name) from ecs_goods就可以直接调用mysql自定义函数了。

?来源:http://www.chinab4c.com

?