涉及的数据库
发布帖子需要几个相关数据库。
pre_forum_thread 主题数据表
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
tid | mediumint(8) | 否 | 无 | 主题id |
fid | mediumint(8) | 否 | 0 | 上级论坛id |
authorid | char(15) | 否 | 无 | 会员名 |
author | mediumint(8) | 否 | 0 | 会员id |
subject | char(80) | 否 | 0 | 帖子标题 |
dateline | int(10) | 否 | 0 | 发表时间 |
lastpost | int(10) | 否 | 0 | 最后发表 |
lastposter | char(15) | 否 | 空 | 最后发表人id |
pre_forum_forum 版块基础信息表
更新该板块对应的fid
的threads
和posts
分别+1
可以用下面的代码操作
C::t('forum_forum')->update_forum_counter($fid,1);
更新一下,可以使用下面的代码更新form_forum
数据表。
DB::query("UPDATE ".DB::table('forum_forum')." SET lastpost='$lastpost', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
forum_newthread 最新主题索引表
直接用下面的代码更新即可
C::t('forum_newthread')->insert(array('tid' => $tid, 'fid' => $fid, 'dateline' => $_G['timestamp']));
引入require_once libfile('function/forum');
中函数:insertpost()
function insertpost($data) {
if(isset($data['tid'])) {
$thread = C::t('forum_thread')->fetch($data['tid']);
$tableid = $thread['posttableid'];
} else {
$tableid = $data['tid'] = 0;
}
$pid = C::t('forum_post_tableid')->insert(array('pid' => null), true);
$data = array_merge($data, array('pid' => $pid));
C::t('forum_post')->insert($tableid, $data);
if($pid % 1024 == 0) {
C::t('forum_post_tableid')->delete_by_lesspid($pid);
}
savecache('max_post_id', $pid);
return $pid;
}
$data值为数组
未完待续...