Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPBuilder.com:
Using the PEAR Pager Package to Paginate MySQL Results
Apr 13, 2011 @ 15:35:40

On PHPBuilder.com today there's a new tutorial about using the PEAR Pager package to paginate through results from a MySQL query. The package makes it easy to pass in a data set and handle the pagination requests and interface.

Fortunately a great solution [for paginating data] is at your disposal which has been created expressly for this purchase. The PEAR Pager package will not only handle all of the gory tracking details for you, but it can also create a linked navigation list which you can embed into the page as a navigational aide for the user. In this article I'll show you how to use Pager to easily paginate your database results in a structured and coherent way.

He walks you through installing the packaged (thankfully easy with the PEAR installer) and how to use it on a simple array dataset of college names. From there he moves into the database realm, creating a simple table that stores the same information and pulling the results out and into the Pager functionality.

tagged: mysql paginate pear pager package tutorial

Link:

NETTUTS.com:
How to Paginate Data with PHP
Feb 06, 2009 @ 13:58:32

This new tutorial from NETTUTS.com answers one of the more common question that gets asked by developers (usually those starting out) - how can I easily paginate my information?

I can remember years ago when I first began coding in PHP and MySQL, how excited I was the first time I got information from a database to show up in a web browser. [...] As a developer, one problem I'm constantly faced with is taking a large set of information and making it easy to digest. Whether its a large company's client list or a personal mp3 catalog, having to sit and stare at rows upon rows upon rows of data can be discouraging and frustrating. What can a good developer do? Paginate!

His method (the source is here) creates its own Pagination class that he extends for his specific example. The class allows the user to select now only which page they want to view but how many they want shown on each page.

tagged: paginate data mysql database tutorial

Link:

DevShed:
Paginating Database Records with the Code Igniter PHP Framework
Aug 28, 2008 @ 12:57:51

DevShed continues their look at using the CodeIginiter PHP framework to build a sample application in this latest part of their series - a look a paginating the database results from a query.

As you may guess, however, Code Igniter comes bundled with a robust set of core classes, which can be used to perform all sorts of clever tasks, such as working with databases, performing file uploads, validating user-supplied data, and so forth. [...] I'm going to show you how to improve the MySQL-driven application developed in the preceding tutorial, since it'll be provided with the capacity for paging database records, via the pager class included with Code Igniter.

He starts by reviewing the previous part of the series, pulling the data from MySQL, then shows how to push that through the pagination component to create a simple user listing.

tagged: codeigniter framework database mysql result query paginate

Link:

Debuggable Blog:
How to do Group By conditions in Model find() calls in the CakePHP RC1
Jun 12, 2008 @ 13:48:09

On the Debuggable blog, Tim Koschutzki shows how to use grouping in your SQL statements with the find() method calls inside of a Model for an app.

We have to thank Mark Story and wluigi for working on group by conditions for Cake's Model::find() method. Up until now, you would have to add your GROUP BY stuff to string'ed conditions in order to support a group by statement, which could be very ugly.

He has some code included that compares the two methods - the newer of the two applying the 'group' option as a regular condition to the query object.

This functionality is currently only in the the Release Candidate 1 but will be included in the next major release.

tagged: cakephp framework groupby grouping conditional paginate

Link:

SaniSoft Blog:
unbindModel() and paginate() gotcha in CakePHP 1.2
Mar 06, 2008 @ 18:59:00

Tarique Sani has pointed out a little "gotcha" he came across when working in his CakePHP application a while back, specifically with the unbindModel and paginate methods.

A small note to myself regarding a gotcha which I ran into today morning with the built in unbindModel method which lets you disassociate model relations on the fly.

He sets up a situation where his model works correctly in one case but reverts back to the bindings it started with in another. He provides a way around it - an optional parameter that forces the CakePHP framework to treat things correctly.

tagged: cakephp framework unbindmodel paginate

Link:


Trending Topics: