

- Using POG with Flex
- Optimizing your web application
- Regenerating large objects
- PHP4 or PHP5
- New and Improved
- Evolution of a cube
- POG Museum
- POG 3.0 alpha
- Initial Performance results Part 2
- Initial performance results
- Proposal: POG 3.0 object model
- Suggest a feature
- A new year, A new POG release
- Many-Many relations
- POG 2.5 Released
- POG 2.5 beta
- Automatic table alignment
- New version: 2.1.2 released
- RSS should work well now
- RSS feed glitches
- What's new in 2.1.0
- PHP Objects 2.1.0 (preview)
- PHP Object relations FAQ
- PHP Object Relations
- Searching base64 encoded text
- How to debug POG-generated objects
- POG UI Tips
- Featuring Of Interest links
- PHP CRUD
- POG 2.0.1: A better code generator
- A look at the POG SOAP API
- POG 2.0.0 released
- Coming soon: Generate parent-child objects
- Generated abstraction v/s dynamic abstraction
- Zend Framework preview
- Coming soon: Generate Objects through SOAP
- Easily save images and files to a database
- PHP, Paypal & POG
- Five advanced Code Generator tips
- PHP Pagination using generated objects
- PHP Code Generator benchmarks
- Representing database objects using an AJAX Tree interface
- Using SETUP in a production environment
- Description of the generated object package
- Introducing PHP Object Generator version 1.6
- Using AJAX and PHP Object Generator
- When to use Object->SaveNew()
- Generating PHP objects in 2006
- Happy Holidays
- A short video of the POG Setup process
- A sneak peek at POG 1.6
- POG Tip: Field limits
- Previous versions.
- Searching the blog and tutorials sections
- Generating code with "Other" SQL data types
- Five general POG tips
- POG source code locations
- Microsoft SQL 2005 Express Edition
- Impatiently awaiting PHP 5.1 and PDO
- Php Object Generator goes open source
- POG generates PDO compatible code
- Oracle to offer free database
- POG Google group
- Database Wrappers and POG
- Revisions
- The generator blog
- An explanation of the 'Escape' function.
- Mirror, mirror
- Using POG to solve real world problems
- A php object-relational database tool
- A simple and flexible Object Oriented approach to PHP

Back to the Code Generator
The POG Google group
The POG tutorials/code samples
The POG mirror site
PHP Pagination using generated objects
written 4717 days agoPHP pagination is often required when you need to create reporting views of your database tables. For example, let’s say you need to create a list of all guests attending a particular event. If you have a ‘Guest’ object, calling
$guest = new Guest();
$guestList = $guest -> GetList(array(array(“guestId”, “>”, 0)));
will return the complete guest list.
However, quite often, the number of results that match the conditions passed to GetList() is quite large, and you need to split your result set across many html pages. This is usually referred to as PHP paging or pagination.
If you were writing your own SQL queries to access your database, and wanted to limit your query result to 50, the query would look something like this:
select * from table guest where guestid > 0 Limit 0, 50.
where 0 is the offset and 50 is the limit. In the query above, mysql would return row 0 to 50 of the result set.
You can use the same concept and syntax with objects generated by POG. To get the first 50 guests from your guest list using the guest object, all you need to do is call
$guest = new Guest();
$guestList = $guest -> GetList(array(array(“guestId”, “>”, 0)), ‘’, true, “0, 50”);
In the above code, instead of passing a simple value to the $limit variable, we passed “0, 50” which allows us to specify the limit and offset of the objects we want. Note that passing “0,50” is equivalent to passing “50”.
So, if we were building a report with 50 guests per html page, the above query would give us the values for the first page. What about the second page? To obtain result set 50-100, we simply call
$guest = new Guest();
$guestList = $guest -> GetList(array(array(“guestId”, “>”, 0)), ‘’, true, “50, 50”);
This tells POG to return 50 results starting from row 50.
Therefore, the pattern can be summarized as follows:
Page 1 – $limit = “0, 50”
Page 2 – $limit = “50, 50”
Page 3 – $limit = “100, 50”
And so on.
As you can see, POG CRUD methods are simple, yet powerful enough to handle PHP pagination.
For a detailed documentation of the GetList CRUD method, please refer to the POG tutorials


This is a weblog about the Php Object Generator (POG) project, OO PHP, databases and Php code generators in general.
Php Object Generator, (POG) is an open source PHP code generator which automatically generates clean & tested Object Oriented code for your PHP4/PHP5 application.
Subscribe to our RSS feed
Feedback, Feature Requests, Bugs to:
The POG Google group
Send us a Hello through email
How can I know the count of objects in database with pog? (pagination is clear)
— elffikk Oct 2, 09:58 AM #