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

想入飞飞1年前记录500

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

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

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;


标签: 帝国cms

相关文章

帝国cms 自定义列表建立tag效果 根据关键字调用

统计记录:(如:select count(*) as total from phome_ecms_news where classid=1 and checked=1)注:这句SQL的意思是查找统计位...

帝国CMS 7.5 数据库重置管理员密码方法教程

通过phpmyadmin登录MYSQL数据库修改管理员密码。1.登陆到phpmyadmin,找到你的网站对应帝国CMS数据库;2.找到******_enewsuser数据表,这个表放着后台的所有用户。...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。