帝国CMS批量提取新闻正文内容的第一张图片作为标题缩略图的SQL语句

帝国CMS批量提取新闻正文内容的第一张图片作为标题缩略图的SQL语句

浏览次数:
作者: 墨鱼
信息来源: 本站原创
更新日期: 2016-02-13 18:41:14
文章简介

执行以下脚本的时候请 先备份数据库!文本存放的新闻正文字段不可用!新闻正文字段作为主表的情况用以下语句:update phome_ecms_news set titlepic =concat(replace(SUBSTRI

  • 正文开始
  • 相关阅读
  • 推荐作品

执行以下脚本的时候请 先备份数据库!文本存放的新闻正文字段不可用!

新闻正文字段作为主表的情况用以下语句:

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;

HTML中通过CSS设置背景图片自适应浏览器大小
« 上一篇 2016年01月23日
记录一次因“大意书写”而导致的“[高危]SQL注入漏洞(盲注)”
下一篇 » 2016年02月29日

如本文对您有帮助,就请墨鱼抽根烟吧!