Welcome Guest, Not a member yet? Register   Sign In
Pagination and Best way for Optimization of data load
#5

[eluser]Unknown[/eluser]
[quote author="[email protected]" date="1371041415"]Hello, CI Pros:

[...]

how can I load only, for example, 100 pages at a time?

[...]

[/quote]

An example would be :

Code:
// get the number of the actual page, if segment 4 isn't set, set to 1
$page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 1;

// get total amount of rows in your table
$total_rows = $this->db->get('YOUR_TABLE')->num_rows();

// items per page
$per_page = 100;

// calculate the starting row
$start_row = $page * $per_page - $per_page;

$query = $this->db->select('WHAT_YOU_WANT')
                  ->from('YOUR_TABLE')
                  ->limit($per_page, $start_row)
                  ->get();

// handle results


Messages In This Thread
Pagination and Best way for Optimization of data load - by El Forum - 06-12-2013, 05:50 AM
Pagination and Best way for Optimization of data load - by El Forum - 06-12-2013, 06:38 AM
Pagination and Best way for Optimization of data load - by El Forum - 06-12-2013, 07:29 AM
Pagination and Best way for Optimization of data load - by El Forum - 06-12-2013, 08:11 AM
Pagination and Best way for Optimization of data load - by El Forum - 06-12-2013, 08:27 AM
Pagination and Best way for Optimization of data load - by El Forum - 06-12-2013, 10:57 AM
Pagination and Best way for Optimization of data load - by El Forum - 06-12-2013, 10:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB