广州传奇网络
地址:广州市天河区东圃大马路富华楼C座
电话:13808825895
QQ:1564443073
“数据库升级”打开数据SQL语句输入表单。
1、清空数据表supe_robotitems和supe_robotmessages:
TRUNCATE TABLE `supe_robotitems`;
TRUNCATE TABLE `supe_robotmessages`;
这两个表是装载采集内容的,如果要清空其它数据表可以自己更换;
2、将SupeSite中所有未审核的内容全部审核为“1级审核”
UPDATE `supe_spaceitems` SET `grade` =1 WHERE `grade` =0 ;
这个方法对采集来几十万,几百万条的站点管理最方便;
3、删除XXX表里的ID1到ID10的行:
delete form xxx where id between 1 and 10;
数据调用:
一、资讯
查资讯自定义字段
SELECT i.*,n.*,c.type as c_type,c.name as c_name,c.displayorder as c_displayorder,c.customfieldtext as c_customfieldtext,c.isdefault as c_isdefault,c.isshare as c_isshare FROM supe_spaceitems i, supe_spacenews n, supe_customfields c WHERE i.itemid = n.itemid AND n.customfieldid = c.customfieldid AND n.customfieldid !=0
通过supe_spaceitems,supe_spacenews,supe_customfields三表联查来取得数据。
查资讯列表,同时查对应的图片附件
SELECT * FROM supe_spaceitems i, supe_attachments a WHERE i.picid = a.aid
查资讯列表和内容,同时查对应的图片附件
SELECT i.*, n.message, a.* FROM supe_spaceitems i, supe_spacenews n, supe_attachments a WHERE i.picid = a.aid AND i.itemid=n.itemid
调用模型中图片,标题,内容数据
SELECT * FROM supe_[模型英文ID]message m,supe_[模型英文ID]items i WHERE m.itemid=i.itemid
supe_[模型英文ID]message 与 supe_[模型英文ID]items 是存储模型信息的主表,添加的字段也会添加在 supe_[模型英文ID]message 里面,将这两个表联起来就可以查询出想要的大部分数据。
二、论坛
查询论坛中今天发帖总数与论坛总帖数
SELECT sum(posts) AS posts , sum(todayposts) AS todayposts FROM cdb_forums
查询论坛主题,在设置主题分类时,显示出主题分类名称
SELECT * FROM cdb_threads t, cdb_threadtypes y WHERE t.typeid = y.typeid
查询论坛的主题,并显示版块名称
SELECT * FROM cdb_threads t, cdb_forums f WHERE t.fid = f.fid
如何调用版块简介
SELECT * FROM cdb_forums s, cdb_forumfields f WHERE s.fid=f.fid
从SS取Discuz!含有图片附件的最新主题
SELECT * , a.attachment AS attachment FROM cdb_threads t, cdb_attachments a, cdb_posts p WHERE t.tid = a.tid AND a.isimage =1 AND p.tid = t.tid AND p.first =1 GROUP BY t.tid ORDER BY t.dateline DESC
读取论坛 某个用户所收藏的主题
SELECT * FROM cdb_favorites f, cdb_members m, cdb_threads t WHERE f.uid = m.uid AND f.tid = t.tid
调用论坛中每个主题调用一张图片的
SELECT a.* , t.* , count( DISTINCT a.tid )
FROM cdb_attachments a, cdb_threads t
WHERE a.tid = (
SELECT t.tid
FROM cdb_threads t
WHERE t.attachment =2
ORDER BY dateline DESC )
GROUP BY a.tid
查询论坛的分类信息
论坛的分类信息是要四表联查的,并且不能一次查出来,分两次,第一次是将主题表与主题类型有联查(数据显示一次)
第二步是查询分类信息的各个选项的值,查询出来后进行循环显示
注意:因为很复杂,具体应用时,要先理解清楚,把SQL在数据库中运行一遍,想好怎么写展示代码
SELECT * FROM cdb_threads t, cdb_threadtypes y WHERE t.sortid = y.typeid AND t.tid=4
SELECT * FROM cdb_typeoptionvars v,cdb_typeoptions o WHERE o.optionid=v.optionid AND v.tid=4 and v.sortid=1
Popularity: 3%