简体   繁体   中英

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

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 :

    $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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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