使用DedeCMS建站會遇到這樣的問題,采集來的文章有個小錯誤沒修正,需要把文章的內容批量替換下,一篇一篇的修改會十分麻煩,這里就需要用到織夢的特有功能,SQL批量替換功能,語法標簽如下:
1.更改文章中的內容
update dede_addonarticle set body=replace(body,'原來的字符','替換后的字符')
例子解釋:update dede_addonarticle set body=replace(body,'軟件下載','插件下載')
2.更改縮略圖目錄
update dede_archives set litpic=replace(litpic,'原來的字符','替換后的字符')
例子解釋:update dede_archives set litpic=replace(litpic,'uplimg,'tupian')
3.批量替換文章模型中內容部分圖片鏈接路徑
update dede_addonarticle set body=replace(body,'src="http://dede58.com/img/','src="http://dede58.com/images/');
例子解釋:把圖片路徑由原來的http://www.dede58.com/img/替換成http://dede58.com/images/
4.批量替換文章模型中內容部分超鏈接
update dede_addonarticle set body=replace(body,'href="http://www.meiowpet.com','href="http://meiowpet.com');
例子解釋:把文章模型中的超鏈接由原來的http://www.yudouyudoucom替換成http://yudouyudoucom
5.批量替換文章模型中內容部分圖片錨文本文字
update dede_addonarticle set body=replace(body,'alt="http://www.dede58.com/','alt="http://dede58.com/');
例子解釋:把文章模型中的圖片錨文本信息由原來的http://www.dede58.com替換成http://dede58.com
6.批量替換軟件模型內容部分超鏈接
update dede_addonsoft set introduce=replace(introduce,'href="http://www.dede58.com/images/js/test.html','href="http:/dede58.com/index.html');
例子解釋:把軟件模型內容中超鏈接由原來的http://www.dede58.com/images/js/test.html替換成http:/yudouyudoucom/index.htm
7.批量替換文章模型中作者字段
update dede_archives set writer=replace(writer,'http://www.dede58.com','http://dede58.com');
例子解釋:把文章模型中的作者由原來的http://www.dede58.com替換成http://dede58.com
8.批量替換文章模型中來源字段
update dede_archives set source=replace(source,'69閣www.dede58.com','織夢58dede58.com');;
例子解釋:把文章模型中的帖子來源由原來的69閣www.dede58.com替換成織夢58dede58.com
9.批量替換文章命名規則
update `dede_arctype` set namerule='{typedir}/{aid}.html';
例子解釋:把站內所有文章模型命名規則全部替換成{typedir}/{aid}.html這樣一種形式
10.批量替換軟件模型演示地址超鏈接
update dede_addonsoft set writer=replace(officialUrl,'http:/www.dede58.com','http://dede58.com');
例子解釋:把軟件模型原始地址超鏈接由原來的http:/www.dede58.com替換成http://dede58.com
11.批量審核文章
update dede_archives set arcrank=0;
例子解釋:arcrank=0 僅動態。