View Single Post
Old 12-12-2007, 09:43 PM   #6 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,239
Thanks: 3
Salathe is on a distinguished road
Default

A fair starting point, but (please correct me if I'm wrong) a pagination class should not be dealing with the database at all. It should just be able to paginate a generic set of 'things' (be they db records, array items, class properties, etc) and be only concerned with doing the job at hand -- paginating. Nothing more!

Now imagine if you had your current class, and decided to use SQLite, XML or even web services as the data source. Would you create x number of pagination classes to fit each data type?

Along similar lines, I think it would also be a good idea to think about the output from the class. Not everyone is going to want to use tables but in your class they're hard-coded. Some other class should be able to take the results from your pagination class and deal with them in any manner -- keeping the system flexible. To sum up, I think this class is trying to do way too many things where it should really be focused on doing one thing, neither grabbing database data nor dictating how the paginated results should be displayed.

I understand that this entire post is pretty much rubbishing your class, but please understand that just because I would do something differently doesn't make it right. At the very least, I hope to have given you some food for thought on what exactly should go in any particular class.
__________________
salathe@php.net
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
Rendair (12-13-2007)