涉及到的數據表:
1、關於主題
一、pw_threads(主題表)
二、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` ='我是內容
2、關於標籤
一、pw_tags(標籤表)
二、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');
3、其餘
一、pw_memberdata(用戶基本信息表)
二、pw_creditlog(積分日誌表)
三、pw_forumdata(版塊內相關統計信息)
四、pw_weibo_content(新鮮事內容表)
五、pw_weibo_relations(新鮮事「我關注的新鮮事」關係表)
六、pw_datanalyse(數據統計信息)
七、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';
php