CodeIgniter Forums
set query offset in active record with join - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: set query offset in active record with join (/showthread.php?tid=16164)



set query offset in active record with join - El Forum - 02-26-2009

[eluser]freshface[/eluser]
I need to set an offset, but how?

Code:
$this->db->select('products_products.id, products_products.reference_id, products_products.stock, products_language_content.name ');
        $this->db->from($this->table);
        $this->db->limit($limit);
        $this->db->where($where);
        $this->db->join('products_language_content', 'products_language_content.product_id = products_products.id', 'right');
        $this->db->where(array('products_language_content.language_id' => LANG_ID));
         $q = $this->db->get()->result();
    
        return count($q) == 0 ? array() : $q;

Any ideas


set query offset in active record with join - El Forum - 02-26-2009

[eluser]Aniket[/eluser]
You can set offset and limit this way
Code:
$this->db->limit($records_per_page,$offset);
$records_per_page refers to the no of records to display
$offest determines the offset.