易学库易学库

易学库(生活百科)
优质互联网资讯分享平台!!!
文章1436浏览166508本站已运行41128

帝国CMS批量提取新闻内容第一张图作为标题缩略图的方法

帝国CMS批量提取新闻内容第一张图作为标题缩略图的方法,执行以下脚本的时候请 先备份数据库!文本存放的新闻正文字段不可用!新闻正文字段作为主表的情况用以下语句:f0B易学库

update phome_ecms_news set titlepic =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext, 'src=', -1),'.gif',1),'"',''),'.gif') where newstext like '%.gif%' and titlepic='';
update phome_ecms_news set titlepic =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext, 'src=', -1),'.jpg',1),'"',''),'.gif') where newstext like '%.jpg%' and titlepic='';
update phome_ecms_news set titlepic =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext, 'src=', -1),'.png',1),'"',''),'.png') where newstext like '%.png%' and titlepic='';
 

新闻正文字段作为副表的情况用以下语句:f0B易学库

update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext, 'src=', -1),'.gif',1),'"',''),'.gif') where a.newstext like '%.gif%' and b.titlepic='' and a.id=b.id;
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext, 'src=', -1),'.jpg',1),'"',''),'.jpg') where a.newstext like '%.jpg%' and b.titlepic='' and a.id=b.id;
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext, 'src=', -1),'.png',1),'"',''),'.png') where a.newstext like '%.png%' and b.titlepic='' and a.id=b.id;
易学库
上一篇: 不再错过短视频风口,用python一键生成短视频,就是这么简单!
下一篇: 如果“被酒驾”,可以怎么做?

相关推荐

隐藏边栏