mardi 12 juillet 2016

How to get large data from db using laravel

I have aprrox. 350000 records in my database and i want to get all those in postman.For that i wrote the code in laravel as follows i.e incementing by each time by 5000.

 public function get() {
  $a = 1;
  $k = 5000;

  for($i = $a;$i <= 300000;$i++){
      for($j = 1;$j <= $k;$i++){
    $res = DB::table('company')
            ->where('source','A')
            ->get();
  }
  $k = $k + 5000;
  if($i < 350000){
  $a = $i + 1;
  }
      }
 if ($res > 0) {
        return Response::json($res);
    } else {
        return Response::json('');
    }

 But i am not getting anything, i am not even able to get count of total records.Is it not possible to get records greater than 5000 at one time?

Aucun commentaire:

Enregistrer un commentaire