Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. $s = 0; //starting offset
  4.  
  5. $l = 200; //limit of rows to select
  6.  
  7. $t = Modal::count(); //1000
  8.  
  9. $n = ceil($t / $l);
  10.  
  11. $c = 0;
  12.  
  13. for ($i = 1; $i <= $n; $i++) {
  14. $from = $s;
  15. $to = $s+$l;
  16.  
  17. $data = Modal::offset($from)->limit($l)->get();
  18. $rows = count($data); //100 at a time
  19.  
  20. echo "{$i} of {$n} --- ";
  21. echo "{$from} -> {$to} (Count: {$rows})\n\n";
  22.  
  23. //Must be done at the end of the loop
  24. $s = $s+$l;
  25. $c = $c+$rows;
  26. }
  27.  
  28. echo "\n\n";
  29.  
  30. $d = $t-$c;
  31. echo "total items: {$t}\n";
  32. echo "total count: {$c}\n";
  33. echo "diff {$d}\n";
  34. echo "limit: {$l}\n";
  35. echo "number: {$n}\n";
  36.  
  37.  
  38.  
  39. /*
  40. ***************************
  41.  
  42. 1 of 5 --- 0 -> 200 (Count: 200)
  43.  
  44. 2 of 5 --- 200 -> 400 (Count: 200)
  45.  
  46. 3 of 5 --- 400 -> 600 (Count: 200)
  47.  
  48. 4 of 5 --- 600 -> 800 (Count: 200)
  49.  
  50. 5 of 5 --- 800 -> 1000 (Count: 200)
  51.  
  52.  
  53.  
  54. total items: 1000
  55. total count: 1000
  56. diff 0
  57. limit: 200
  58. number: 5
  59.  
  60. ***************************
  61. * */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement