用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3909|回复: 3
收起左侧

STBbog的posts表数据超过一万的时候,翻页会不会出错?疑问

[复制链接]
发表于 2013-4-1 16:26:00 | 显示全部楼层 |阅读模式
有一个疑问,先贴代码:
PHP复制代码
public function get_posts($type = 'post',$status = 'publish',$author_id = NULL,$limit = NULL,$offset = NULL,$category_filter = 0, $title_filter = '', $feed_filter = FALSE)
 {
  $this->db->select('posts.*, users.screenName');
  $this->db->join('users','users.uid = posts.authorId');
 
  //type
  if($type && in_array($type, $this->_post_type))
  {
   $this->db->where('posts.type', $type);
  }
 
  //status
  if($status && in_array($status,$this->_post_status))
  {
   $this->db->where('posts.status', $status);
  }
 
  //author
  if(!empty($author_id))
  {
   $this->db->where('posts.authorId', intval($author_id));
  }
 
  //category filter
  if(!empty($category_filter))
  {
   $this->db->join('relationships','posts.pid = relationships.pid','left');
   $this->db->where('relationships.mid', intval($category_filter));
  }
 
  //title filter
  if(!empty($title_filter))
  {
   $this->db->like('posts.title', $title_filter);
  }
 
  //feed filter
  if($feed_filter)
  {
   $this->db->where('allowFeed', 1);
  }
 
  $this->db->order_by('posts.created','DESC');
 
  //limit
  if($limit && is_numeric($limit))
  {
   $this->db->limit(intval($limit));
  }
 
  //offset
  if($offset && is_numeric($offset))
  {
   $this->db->offset(intval($offset));
  }
 
  return $this->db->get(self::TBL_POSTS);
 }
 
复制代码


翻页查数据总记录数的时候有这么一个代码片段
PHP复制代码
   $posts = $this->posts_mdl->get_posts('post', $status, $author_id, $limit, $offset, $category_filter, $title_filter);
  $posts_count = $this->posts_mdl->get_posts('post', $status, $author_id, 10000, 0, $category_filter, $title_filter)->num_rows();
复制代码


疑问在$posts_count = $this->posts_mdl->get_posts('post', $status, $author_id, 10000, 0, $category_filter, $title_filter)->num_rows();问题出在10000这里,如果posts表里面的文章数,超过一万条的时候,它是不是就只统计到一万条,然后翻页的逻辑就会出现错误????

可能我对代码的理解出现了误解,所以贴上来,看看有没有这么一回事

发表于 2013-4-1 16:41:49 | 显示全部楼层
应该会影响的吧,可能老大考虑说能写10000篇日志就毕业了。
我帮你咨询下。
发表于 2013-4-1 17:39:40 | 显示全部楼层
楼上完全正确,加100分奖励我的香吻一个。

这里的确偷了个懒。
发表于 2013-5-24 18:31:47 | 显示全部楼层
写了一w篇blog的时候,你完全可以自己修复它了

本版积分规则