insert,update商品数据时需要把content中只截取前8个图片
tirgger语句:
create trigger tri_goods_update AFTER UPDATE
on ims_ewei_shop_goods for each row
begin
set @gcount = (SELECT CAST((LENGTH('content') - LENGTH(REPLACE('content',"absmiddle", ""))) / LENGTH("absmiddle") AS signed) AS count FROM ims_ewei_shop_goods where id = new.id);
IF @gcount > 8 AND locate('
',old.content) = 0 THEN
update ims_ewei_shop_goods set content = CONCAT(substring_index(old.content,'absmiddle',-(@gcount - 8)),'absmiddle" >') where id = new.id;
END IF;
END
触发器创建,和修改执行后没有报错,content中的数据没有改变.
白猪掌柜的
相关分类