Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $s = 0; //starting offset
- $l = 200; //limit of rows to select
- $t = Modal::count(); //1000
- $n = ceil($t / $l);
- $c = 0;
- for ($i = 1; $i <= $n; $i++) {
- $from = $s;
- $to = $s+$l;
- $data = Modal::offset($from)->limit($l)->get();
- $rows = count($data); //100 at a time
- echo "{$i} of {$n} --- ";
- echo "{$from} -> {$to} (Count: {$rows})\n\n";
- //Must be done at the end of the loop
- $s = $s+$l;
- $c = $c+$rows;
- }
- echo "\n\n";
- $d = $t-$c;
- echo "total items: {$t}\n";
- echo "total count: {$c}\n";
- echo "diff {$d}\n";
- echo "limit: {$l}\n";
- echo "number: {$n}\n";
- /*
- ***************************
- 1 of 5 --- 0 -> 200 (Count: 200)
- 2 of 5 --- 200 -> 400 (Count: 200)
- 3 of 5 --- 400 -> 600 (Count: 200)
- 4 of 5 --- 600 -> 800 (Count: 200)
- 5 of 5 --- 800 -> 1000 (Count: 200)
- total items: 1000
- total count: 1000
- diff 0
- limit: 200
- number: 5
- ***************************
- * */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement