打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[分享]一些SQL语句|帝国CMS-狂人采集器 - Powered by phpwind
分享]一些SQL语句

[分享]一些SQL语句
一些SQL语句
update  phome_ecms_表名  set  titlepic=''...
这个是去除预览图的项。不过图片不删除

整理标题重复数据的sql语句[终极优化版]

第一次运行:

--------------------------------------------------------------------------------

/****建立临时表,结构与phome_ecms_news相同字段,主键为title****/
create  table  phome_ecms_news_tmp  (id  int(11)  NOT  NULL  ,  classid  smallint(6)  NOT  NULL,  onclick  int(11)  NOT  NULL,  newspath  varchar(50)  NOT  NULL,  keyboard  varchar(255)  NOT  NULL,  keyid  varchar(255)  NOT  NULL,  userid  int(11)  NOT  NULL,  username  varchar(30)  NOT  NULL,  ztid  text  NOT  NULL,  checked  tinyint(1)  NOT  NULL,  istop  tinyint(4)  NOT  NULL,  truetime  int(11)  NOT  NULL,  ismember  tinyint(1)  NOT  NULL,  dokey  tinyint(1)  NOT  NULL,  userfen  int(11)  NOT  NULL,  isgood  tinyint(1)  NOT  NULL,  titlecolor  varchar(10)  NOT  NULL,  titlefont  varchar(255)  NOT  NULL,  titleurl  varchar(200)  NOT  NULL,  filename  varchar(60)  NOT  NULL,  filenameqz  varchar(28)  NOT  NULL,  fh  tinyint(1)  NOT  NULL,  groupid  smallint(6)  NOT  NULL,  newstempid  smallint(6)  NOT  NULL,  plnum  int(11)  NOT  NULL,  firsttitle  tinyint(1)  NOT  NULL,  checkuser  text  NOT  NULL,  docheckuser  text  NOT  NULL,  viewcheckuser  text  NOT  NULL,  returncheck  tinyint(1)  NOT  NULL,  notdocheckuser  text  NOT  NULL,  totaldown  int(11)  NOT  NULL,  title  varchar(200)  NOT  NULL,  newstime  datetime  DEFAULT  '0000-00-00  00:00:00'  NOT  NULL,  titlepic  varchar(200)  NOT  NULL,  wplay  tinyint(1)  NOT  NULL,  ftitle  varchar(200)  NOT  NULL,  smalltext  text  NOT  NULL,  writer  varchar(30)  NOT  NULL,  befrom  varchar(60)  NOT  NULL,  newstext  mediumtext  NOT  NULL,  closepl  tinyint(1)  NOT  NULL,  havehtml  tinyint(1)  NOT  NULL,  PRIMARY  KEY  (title),  KEY  classid  (classid));

--------------------------------------------------------------------------------


以后运行:

--------------------------------------------------------------------------------

/****将标题重复的数据倒入临时表****/
insert  ignore  into  phome_ecms_news_tmp  select  distinct  *    from  phome_ecms_news  group  by  title  having  count(*)>1;
/****将原表标题重复的条目重命名为特殊字段****/
update  phome_ecms_news  as  t1,phome_ecms_news_tmp  as  t2  set  t1.title  ='[1234567890}'  where  t1.title=t2.title;
/****删除原表内标题为特殊字段的条目****/
delete  from  phome_ecms_news  where  title='[1234567890}';
/****将临时表条目倒回****/
insert  ignore  into  phome_ecms_news  select  distinct  *  from  phome_ecms_news_tmp;
/****清空临时表(可选)****/
truncate  phome_ecms_news_tmp;



delete from phome_ecms_news where newstext = '';
清除空數據


栏目:phome_enewsclass
采集:phome_enewsinfoclass与phome_ecms_infoclass_表名


让标签参数支持模板变量说明:以实现按各种条件调用信息数据。
根据程序扩展变量的说明得出我们可以在标签参数中直接使用“字段值数组”变量。

例如:我们要列出所有信息来源相同的10条信息,标签如下(按sql语句调用):
[phomenews]"select * from phome_ecms_news where befrom='".$navinfor[befrom]."' order by id desc limit 10",10,32,0,24,0[/phomenews]
附加说明:$navinfor[字段名]

如果要全部审核,运行下面sql:
update  phome_ecms_news  set  checked=1;  


利用sql批量修改栏目信息页命名方式(大家可以举一反三)

批量修改栏目信息页命名方式

有3种
分别是id    time()    md5()    对应的字段值是0    1    2

执行SQL语句
UPDATE    `phome_enewsclass`    SET    `filename`=1    WHERE    `filename`=0;

这样是批量把所有的栏目设置为time()更改完要更新缓存

其他的可以举一反三

比如

UPDATE    `phome_enewsclass`    SET    `lencord`=40;
UPDATE    `phome_enewsclass`    SET    `newstempid`=2;


文章存放方式另类技巧,也许对SEO好吧.

这个方法需要花点时间去完成,要有耐心

使文章都放在  /html  目录下.

1.使用自定义信息列表,定义每个终极栏目的列表.
2.利用sql  语句修改终极栏目的存放目录.


1.自定请信息列表具体使用,不说了,简单明了.
使用这个定义出每个栏目的列表.

2.修改栏目目录  语句update  phome_enewsclass  set    classpath='html'  where  classid=终极栏目ID
其中
html为你要存放的目录
把每个终极类的都改为html,这里就不要列表模版了,以免重复生成。
栏目里不要列表了,因为列表用自定义信息列表了处理了。


显示总记录数:maxnum
生成信息每页显示:lencord
相关链接显示:link_num
信息页文件扩展名:filetype
信息页目录存放形式:newspath


执行以下SQL语句:
update phome_enewsclass set lencord=REPLACE(lencord,'原数据','新数据')

phome_enewsclass 栏目分类表



SQL标签的应用
已带模版的标签为例:
[ecmsinfo]"select  *  from  phome_ecms_news  where  newstime  >  SUBDATE(NOW(),INTERVAL  30  DAY)  order  by  onclick  desc  limit  10",10,30,0,24,7,0[/ecmsinfo]

注意红色部分:
30  是单位(天,当然你也可以修改单位为hour(小时),month(月)等…),自己修改合适的时间。
10  是调用多少条,自己修改为合适。
24  是SQL标签的类型,必须为24系统才会执行前面的SQL。

问:能否指定栏目调用呢?
[ecmsinfo]"select  *  from  phome_ecms_news  where  newstime  >  SUBDATE(NOW(),INTERVAL  30  DAY)  AND  classid  in('2','3')  order  by  onclick  desc  limit  10",10,30,0,24,7,0[/ecmsinfo]

注意红色部分:可以填写你需要调用的栏目ID(注意:必须为终极类)

问:那调用当前栏目呢?这样模就更自动化了。

首先要使模版支持程序代码:
具体操作:后台—系统设置—参数设置—信息设置—模板是否支持程序代码:选择(是)
标签如下:
<?
global  $navclassid;
?>
[ecmsinfo]"select  *  from  phome_ecms_news  where  newstime  >  SUBDATE(NOW(),INTERVAL  30  DAY)  and  classid=$navclassid  order  by  onclick  desc  limit  10",10,30,0,24,7,0[/ecmsinfo]

注意红色部分:
global  $navclassid;,是使列表模版支持$navclassid变量($navclassid为当前栏目ID的变量)。
classid=$navclassid,条件语句,只调用栏目ID=当前栏目ID的文章。


问:我要在内容页调用当前内容页所属栏目的分时热门新闻呢?
[ecmsinfo]"select  *  from  phome_ecms_news  where  newstime  >  SUBDATE(NOW(),INTERVAL  30  DAY)  and  classid='".$navinfor[classid]."'  order  by  onclick  desc  limit  10",10,30,0,24,7,0[/ecmsinfo]

評論調用標簽
<script src=http://www.jztop.com/e/pl/more?classid=108&id=11850&num=10></script>

文章第一副图片做为标题图


--------------------------------------------------------------------------------
update  phome_ecms_news  set  titlepic  =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext,  'src=',  -1),'.jpg',1),'"',''),'.jpg')  where  newstext  like  '%.jpg%'  and  titlepic=''
update  phome_ecms_news  set  titlepic  =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext,  'src=',  -1),'.gif',1),'"',''),'.gif')  where  newstext  like  '%.gif%'  and  titlepic='';


[ecmsinfo]"select  *  from  phome_ecms_article  where  classid!='不显示的栏目ID'  order  by  id  desc  limit  显示条数",显示条数,标题截取数,是否显示时间,24,是否显示栏目名,'时间格式化'[/ecmsinfo]


DELETE FROM phome_ecms_news WHERE newstext like '%版权%'

让标签参数支持模板变量说明:以实现按各种条件调用信息数据。

根据程序扩展变量的说明得出我们可以在标签参数中直接使用“字段值数组”变量。

例如:我们要列出所有信息来源相同的10条信息,标签如下(按sql语句调用):
[phomenews]"select * from phome_ecms_news where befrom='".$navinfor[befrom]."' order by id desc limit 10",10,32,0,24,0[/phomenews]
附加说明:$navinfor[字段名]  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
帝国cms把文章内容中包含某个词全部替换成另外的词
MyBatis动态SQL详解
MyBatis学习 之 三、动态SQL语句
帝国CMA标签
帝国cms灵动标签调用归档信息
MyBatis动态SQL标签用法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服