0xz 发表于 2013-4-1 16:26:00

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

有一个疑问,先贴代码:
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);
}


翻页查数据总记录数的时候有这么一个代码片段
   $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表里面的文章数,超过一万条的时候,它是不是就只统计到一万条,然后翻页的逻辑就会出现错误????

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

jeongee 发表于 2013-4-1 16:41:49

应该会影响的吧,可能老大考虑说能写10000篇日志就毕业了。;P
我帮你咨询下。

saturn 发表于 2013-4-1 17:39:40

楼上完全正确,加100分奖励我的香吻一个。:kiss:

这里的确偷了个懒。

lllccc 发表于 2013-5-24 18:31:47

:lol写了一w篇blog的时候,你完全可以自己修复它了
页: [1]
查看完整版本: STBbog的posts表数据超过一万的时候,翻页会不会出错?疑问