2015-03-18 09:21:24
来 源
中存储网
DedeCMS
做DEDECMS站的朋友通常都会有大量的内容,有时候免不了要做批量性的作业,在这里介绍下dedecms 使用sql语句批量替换的方法。

做DEDECMS站的朋友通常都会有大量的内容,有时候免不了要做批量性的作业,比如N多个栏目修改文章的命名方式,栏目的命名方式等,比如要替换采集上千上万内容中的某个关键词,这时候用手工一条一条修改那是不可能的,在这里介绍下dedecms 使用sql语句批量替换的方法:

一、批量修改文章和目录名:

select namerule from dede_arctype

select namerule2 from dede_arctype
update dede_arctype set namerule='{typedir}/{aid}.html'
update dede_arctype set namerule2='{typedir}/list_{page}.html'

二、利用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://itcaigou.com.cn/img/','src="http://itcaigou.com.cn/images/');

例子解释:把图片路径由原来的http://www.itcaigou.com.cn/img/替换成http://itcaigou.com.cn/images/

4.批量替换文章模型中内容部分超链接

update dede_addonarticle set body=replace(body,'href="http://www.itcaigou.com.cn','href="http://itcaigou.com.cn');

例子解释:把文章模型中的超链接由原来的http://www.itcaigou.com.cn替换成http://itcaigou.com.cn

5.批量替换文章模型中内容部分图片锚文本文字

update dede_addonarticle set body=replace(body,'alt="http://www.itcaigou.com.cn/','alt="http://itcaigou.com.cn/');

例子解释:把文章模型中的图片锚文本信息由原来的http://www.itcaigou.com.cn替换成http://itcaigou.com.cn

6.批量替换软件模型内容部分超链接

update dede_addonsoft set introduce=replace(introduce,'href="http://www.itcaigou.com.cn/images/js/test.html','href="http:/itcaigou.com.cn/index.html');

例子解释:把软件模型内容中超链接由原来的http://www.itcaigou.com.cn/images/js/test.html替换成http:/itcaigou.com.cn/index.htm

7.批量替换文章模型中作者字段

update dede_archives set writer=replace(writer,'http://www.itcaigou.com.cn','http://itcaigou.com.cn');

例子解释:把文章模型中的作者由原来的http://www.itcaigou.com.cn替换成http://itcaigou.com.cn

8.批量替换文章模型中来源字段

update dede_archives set source=replace(source,'采购网www.itcaigou.com.cn','采购网itcaigou.com.cn);

例子解释:把文章模型中的帖子来源由原来的采购网www.itcaigou.com.cn替换成采购网itcaigou.com.cn

9.批量替换文章命名规则

update `dede_arctype` set namerule='{typedir}/{aid}.html';

例子解释:把站内所有文章模型命名规则全部替换成{typedir}/{aid}.html这样一种形式

10.批量替换软件模型演示地址超链接

update dede_addonsoft set writer=replace(officialUrl,'http:/www.itcaigou.com.cn','http://itcaigou.com.cn');

例子解释:把软件模型原始地址超链接由原来的http:/www.itcaigou.com.cn替换成http://itcaigou.com.cn

11.批量审核文章

update dede_archives set arcrank=0;
update dede_arctiny set arcrank=0;
update dede_taglist set arcrank=0;

例子解释:arcrank=0 仅动态

最后,这些语句通用于DEDECMS5.7及更老的版本,因为是安装mysql的语句规则来的,是通用的。

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。