0

I need help trying to get all the rows that meet the condition provided by the WHERE clause starting at an specified OFFSET with no specified LIMIT but I'm only getting an empty result.

The code I'm using is this:

$places = Place::where('category', '=', $category)
    ->skip($padding)
    ->take(18446744073709551615)
    ->get();

return Response::json($places);

I'm using that argument for the take function according to this other question.

Community
  • 1
  • 1
Isaias
  • 329
  • 3
  • 8
  • 22

1 Answers1

0

I've tested, and it seems like if the number is too large you will get an error. Since I don't know what the max number might be, I will suggest you to run an extra query on your DB and have the following:

$limit = Place::all()->count() - $padding;
$places = Place::where('category', '=', $category)
    ->skip($padding)
    ->take($limit)
    ->get();

return Response::json($places);

you can also use $limit = Place::all()->count() and it will work just fine.

NOTE: You can also use trial/error approach to find out the correct value to insert in TAKE

clod986
  • 2,313
  • 5
  • 20
  • 47