如何使用连接查询添加偏移量和限制?

Han*_*nah 1 php mysql codeigniter

我是 codeigniter 的新手,我已经完成了以下代码

public function members($limit, $offset)
{
$this->load->model('Management/Member_model', 'member');
    $this->db->reset_query();
    $this->db->select('*');
    $this->db->from($this->member->table);
    $this->db->join('ib_communities_dtl','ib_communities_dtl.dtl_user_id='.$this->member->table.'.user_id','inner');
    $this->db->join('ib_communities','ib_communities_dtl.dtl_community_id=ib_communities.community_id','inner');
    $this->db->where('ib_communities.community_id', $this->community_id);

  return $this->db->get()->result('Member_model');
}
Run Code Online (Sandbox Code Playgroud)

我想为上述查询添加偏移量和限制,任何人都可以帮我修改它来实现这一点吗?

提前致谢

小智 5

public function members($limit, $offset)
{
$this->load->model('Management/Member_model', 'member');
    $this->db->reset_query();
    $this->db->select('*');
    $this->db->from($this->member->table);
    $this->db->join('ib_communities_dtl','ib_communities_dtl.dtl_user_id='.$this->member->table.'.user_id','inner');
    $this->db->join('ib_communities','ib_communities_dtl.dtl_community_id=ib_communities.community_id','inner');
    $this->db->where('ib_communities.community_id', $this->community_id);
$this->db->limit($limit, $offset);

  return $this->db->get()->result('Member_model');
}
Run Code Online (Sandbox Code Playgroud)