zenghansen

comment_table表

comment表

 

comment_data_x表

 

我们留意到:

  1. comment_table表统计每个comment_data_x表里面有多少条记录,
  2. comment表只是记录文章id和tableid,
  3. 而comment_data_x则是记录评论信息。

实际上,v9的分表逻辑很简单,如果某个文章要新增评论,则判断comment表有无记录,有则这条记录不进行分表判断,若无记录,则判断comment_table的最后一个表是否达到了分表的条件。

if (!$comment = $this->comment_db->get_one(array(\'commentid\'=>$commentid, \'siteid\'=>$siteid), \'tableid, commentid\')) { //评论不存在
//取得当前可以使用的内容数据表
$r = $this->comment_table_db->get_one(\'\', \'tableid, total\', \'tableid desc\');
$tableid = $r[\'tableid\'];
if ($r[\'total\'] >= 1) {
//当上一张数据表存的数据已经达到1000000时,创建新的数据存储表,存储数据。
if (!$tableid = $this->comment_table_db->creat_table()) {
$this->msg_code = 4;
return false;
}
}
}

这样做的好处也很简单,避免了同一个文章的评论分散在不同的comment_data_x表里面。

分类:

技术点:

相关文章:

  • 2021-11-02
  • 2021-05-22
  • 2021-08-19
  • 2021-12-07
  • 2021-07-30
  • 2021-08-25
  • 2021-04-27
  • 2021-04-17
猜你喜欢
  • 2021-06-08
  • 2021-10-18
  • 2021-12-26
  • 2021-07-07
  • 2021-10-12
  • 2021-10-13
  • 2021-11-19
相关资源
相似解决方案