您现在的位置是:首页 > 教程 > 帝国CMS教程帝国CMS教程

帝国CMS批量提取第一张图片为标题缩略图的方法

黎舒旺2023-06-11 00:25:56帝国CMS教程已有人查阅

导读执行SQL语句时请先备份数据库!位置:后台>系统>备份与恢复数据>执行SQL语句新闻正文字段作为主表的情况用以下语句:

执行SQL语句时请先备份数据库!位置:后台>系统>备份与恢复数据>执行SQL语句新闻正文字段作为主表的情况用以下语句:
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='';
新闻正文字段作为副表的情况用以下语句:
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;

本文标签:

很赞哦! ()

留言与评论 (共有 条评论)
验证码:

相关标签