涉及到的数据表:
一、关于主题
1、pw_threads(主题表)
2、pw_tmsgs(帖子内容信息表)
(1) 发布帖子是,主题帖子信息入库
INSERT INTO `pw_threads` SET `fid` = '2' , `icon` = '0' , `author` = 'admin' , `authorid` = '1' , `subject` = '我是标题' , `ifcheck` = '1' , `type` = '0' , `postdate` = '1386034676' , `lastpost` = '1386034676' , `lastposter` = 'admin' , `hits` = '1' , `replies` = '0' , `topped` = '0' , `digest` = '0' , `special` = '0' , `state` = '0' , `ifupload` = '0' , `ifmail` = '0' , `anonymous` = '0' , `ptable` = '' , `ifmagic` = '0' , `ifhide` = '0' , `tpcstatus` = '0' , `modelid` = '0' , `frommob` = ''
(2) 然后帖子内容信息入库
INSERT INTO pw_tmsgs SET `tid` ='1', `aid` ='0', `userip` ='127.0.0.1', `ifsign` ='1', `buy` ='', `ipfrom` ='本机地址
', `tags` ='我是标签 ', `ifconvert` ='1', `ifwordsfb` ='1', `content` ='我是内容
二、关于标签
1、pw_tags(标签表)
2、pw_tagdata(标签关系表)
(1) 首先查找标签是否存在
SELECT tagid FROM pw_tags WHERE tagname= '我是标签';
(2) 如果不存在则在标签表插入该标签,并获得标签唯一id(tagid)
INSERT INTO pw_tags SET `tagname` ='我是标签', `num` ='1';
然后在标签和主题关系表插入关系信息
INSERT INTO pw_tagdata (tagid,tid) VALUES ('1','1');
三、其他
1、pw_memberdata(用户基本信息表)
2、pw_creditlog(积分日志表)
3、pw_forumdata(版块内相关统计信息)
4、pw_weibo_content(新鲜事内容表)
5、pw_weibo_relations(新鲜事“我关注的新鲜事”关系表)
6、pw_datanalyse(数据统计信息)
7、pw_member_behavior_statistic(用户连续行为统计表)
(1) 更新该用户的统计信息
UPDATE pw_memberdata SET money=money+1, rvrc=rvrc+10 WHERE uid= '1';
UPDATE `pw_memberdata` SET `postnum` = '4' , `todaypost` = '3' , `monthpost` = '4' , `lastpost` = '1386144276' , `uploadtime` = '1386142361' , `uploadnum` = '2' WHERE uid= '1'
(2) 更新积分日志
INSERT INTO pw_creditlog (uid,username,ctype,affect,adddate,logtype,ip,descrip) VALUES ('1','admin','money','1','1386034676','topic_Post','127.0.0.1','[b]admin[/b] 在版块 默认版块 发表主题。
奖励积分:[b]铜币[/b],影响:+1。');
(3) 板块统计信息变更
UPDATE pw_forumdata SET tpost=tpost+'1',article=article+'1',topic=topic+'1' ,lastpost= '我是标题 admin 1386034676 read.php?tid=1&page=e#a' WHERE fid= '2'
(4) 新鲜事入库
INSERT INTO `pw_weibo_content` SET `uid` = '1' , `username` = 'admin' , `content` = '我是内容' , `postdate` = '1386034676' , `type` = '10' , `objectid` = '1' , `contenttype` = '0' , `extra` = 'a:4:{s:5:\"title\";s:8:\"我是标题\";s:3:\"fid\";i:2;s:5:\"fname\";s:8:\"默认版块\";s:7:\"atusers\";N;}'
(5) 新鲜事“我关注的新鲜事”关系表
INSERT INTO `pw_weibo_relations` SET `uid` = '1' , `mid` = '1' , `authorid` = '1' , `type` = '10' , `postdate` = '1386034676';
INSERT INTO pw_weibo_relations (uid,mid,authorid,type,postdate) SELECT a.uid, '1' , '1' , '10' , '1386034676' FROM pw_attention a LEFT JOIN pw_friends f ON a.uid=f.uid AND a.friendid=f.friendid AND f.status=0 LEFT JOIN pw_ouserdata o ON a.uid=o.uid WHERE a.friendid= '1' AND a.uid!=a.friendid AND (o.uid IS NULL OR (o.friend_isfollow=1 AND f.uid IS NOT NULL OR o.cnlesp_isfollow=1 AND f.uid IS NULL)) ORDER BY a.joindate DESC LIMIT 1000;
(6) 数据统计信息
SELECT timeunit FROM pw_datanalyse WHERE tag= '1' AND action= 'memberThread';
REPLACE LOW_PRIORITY INTO pw_datanalyse (tag,action,timeunit,num) VALUES ( '1' , 'memberThread' , '1386000000' , '1' ),( '1' , 'memberThread' , '0' , '1' );
(8) 用户连续行为统计表
SELECT * FROM pw_member_behavior_statistic WHERE uid= '1' AND behavior= '3' LIMIT 1;
INSERT INTO `pw_member_behavior_statistic` SET `uid` = '1' , `behavior` = '3' , `lastday` = '1386000000' , `num` = '1';
SELECT * FROM pw_member_behavior_statistic WHERE uid= '1' AND behavior= '2' LIMIT 1;
INSERT INTO `pw_member_behavior_statistic` SET `uid` = '1' , `behavior` = '2' , `lastday` = '1386000000' , `num` = '1';