|
有一个疑问,先贴代码:
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表里面的文章数,超过一万条的时候,它是不是就只统计到一万条,然后翻页的逻辑就会出现错误????
可能我对代码的理解出现了误解,所以贴上来,看看有没有这么一回事
|
|