aarondfrancis / fast-paginate

A fast implementation of offset/limit pagination for Laravel.
MIT License
1.21k stars 56 forks source link

perPage -1 will give zero (0) result instead of all result #39

Closed sawirricardo closed 1 year ago

sawirricardo commented 2 years ago

before, using paginate(-1) will give you "all" results.

But it seems fastPaginate(-1) gives us zero results.

The issue maybe because of fastPaginate under the hood uses simplePaginate(), which also returns 0 with if supplied with per page -1

standar query

image

fast paginate query

image
aarondfrancis commented 2 years ago

Interesting! I didn't know that about -1, I'll add a test for that and fix it. Thanks!

sawirricardo commented 2 years ago

Yeah, it's a trick if you want to show all the records without making additional count query. though after further investigation, it seems to be the simplePagination issue?

ustabasiibrahim commented 2 years ago

this using is really interesting, so what is the advantage or disadvantage of this using?

lucianobosco commented 1 year ago

Landed here looking for how to get all records without limit. Any advice? I'm using 99999 value but it looks like a horrible hack.

aarondfrancis commented 1 year ago

I can't figure out how this is supposed to work. Doing User::paginate(-1) throws an error for me on MySQL. What database are y'all using? Either way, I added a check to see if the page is -1 and if it is it will defer to the Laravel methods.

https://github.com/hammerstonedev/fast-paginate/commit/e0dc0839d90e17d16ae93375cbebd9dbfccb16f7