Exploring library package for a beginner programmer?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
bookDig
Forum Newbie
Posts: 3
Joined: Wed Apr 13, 2016 2:12 pm

Exploring library package for a beginner programmer?

Post by bookDig »

So I am working on project and I need to apply pagination to it what I am facing is the choice whether I should develop my own code or should I study the pagination library of Laravel I admit the ideal thing would be to first develop it on my own to see how it works but the issue is that I am at a deadline in training period and I have to learn to explore libraries to develop market oriented apps. So would someone kindly recommend me. :|
User avatar
Celauran
Moderator
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Exploring library package for a beginner programmer?

Post by Celauran »

I'd do it yourself for the learning experience. Pagination isn't that hard, really. Total items / items per page is your page count. Current page * items per page is your offset. Beyond that it's really just a SELECT statement.
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Exploring library package for a beginner programmer?

Post by Christopher »

If it is data in a database, you may need to SELECT COUNT(*) WHERE ... first to get the total records, and then SELECT * WHERE ... LIMIT to get a page worth.
(#10850)
thinsoldier
Forum Contributor
Posts: 367
Joined: Fri Jul 20, 2007 11:29 am
Contact:

Re: Exploring library package for a beginner programmer?

Post by thinsoldier »

Christopher wrote:If it is data in a database, you may need to SELECT COUNT(*) WHERE ... first to get the total records, and then SELECT * WHERE ... LIMIT to get a page worth.
But only if you need to show the total and/or a list of links to go to each page of results. When you have a huge amount of records it might be best to stick to previous and next links and avoid the extra query.
Warning: I have no idea what I'm talking about.
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Exploring library package for a beginner programmer?

Post by Christopher »

thinsoldier wrote:But only if you need to show the total and/or a list of links to go to each page of results. When you have a huge amount of records it might be best to stick to previous and next links and avoid the extra query.
This depends on the database. Some databases do not have to scan all records to return a row count. Also, this operation only needs to be performed once when entering the paginated set. Thereafter, it can be passed as a parameter or held in the session.
(#10850)
Post Reply