简体   繁体   English

Codeigniter数据库获取问题

[英]codeigniter database fetching problems

public function fetch_user_added_ads_display() {
    $this->db->select('*');
    $this->db->from('user_added_ads');
    $this->db->join('media_ads','media_ads.user_added_ads_id=user_added_ads.user_added_ads_id');
    $this->db->group_by('user_added_ads.user_added_ads_id');
    $this->db->limit('3');
    $q=$this->db->get();

    return $q->result();
}

Hello friends can anyone please suggest me how can i fetch data from database, that is i need from 4th row to 8th row,so how can i do it in codeigniter 朋友您好,有人可以建议我如何从数据库中获取数据,即我需要从第4行到第8行,那么我该如何在codeigniter中进行操作

as per my opinion 根据我的意见

 $this->db->limit('3');

change this code use below code 更改此代码使用下面的代码

$this->db->limit(5,3);

it will work 它会工作

If you want to fetch data from row 4th to 8th then please edit limit line as follow : 如果要从第4行到第8行获取数据,请按如下所示编辑限制行:

    $this->db->limit(3,4);

Here 3 is offset which is the 4th one as it starts from 0. 4 specify no of records to be fetched. 这里3是偏移量,它是从0开始的第4个偏移量。4指定要提取的记录数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM