Generic paging class

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
PCSpectraRetired
Forum Newbie
Posts: 10
Joined: Sun Aug 28, 2005 7:55 pm

Generic paging class

Post by PCSpectraRetired »

I HATE writing code for pagination of records and having to keep track of the page index, number of items to display, etc...so I have considered trying to invent some generic paging class to assist in the madness...

I have looked at all the PHP Paging classes out there (from what could be easily found via Google anyways) and none really appeal to me. There either tied to a specific database like MySQL or require to much tinkering and tweaking to get working.

So my question then is:

Has anyone ever used a PHP Paging class which just dropped into their code and was ready to go? Can I have the link so as to steal ideas from a existing solid class or use it directly if it's good enough.

What I have considered thus far is a class which uses a callback to fill an array from whatever data source desired.

- RDBMS
- Flat file
- XML
- LDAP, etc...

Of course this creates problems onto it's own, cuz now you need a callback to get the total number of records, etc...

Anyways, just an idea I figured I'd blow by you guys and see what I could back as far as feedback :)

Cheers :)
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

I have written one such function that is inspired by that WROX book :arrow: PHP & MySQL - Problem Design Solution or something like that. It takes two params- an array of record to displayed on that page and total no. of records. the no. of records to be displayed is controlled by a global var.

HIH :wink:
Post Reply