Book Image

CakePHP 2 Application Cookbook

By : James Watts, Cake Software Foundation, Inc.
Book Image

CakePHP 2 Application Cookbook

By: James Watts, Cake Software Foundation, Inc.

Overview of this book

Table of Contents (20 chapters)
CakePHP 2 Application Cookbook
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Pagination


CakePHP provides a core Pagination component to process the request parameters in the controller and build the model queries to retrieve paginated data. Instead of getting all the rows from your table, based on the current request parameters, the Pagination component will retrieve only the current page, defined as a limited amount of rows. Of course, all of the pagination settings can be configured, such as to define a specific page limit or change the default ordering of the paginated data.

Just after creating your initial CRUD for any database table, you'll get a fully paginated index view. In this recipe, we'll tweak the pagination defaults to use some URL query string parameters instead of named parameters (named params are deprecated in CakePHP 3.0).

You'll identify named parameters when your website's URL looks something like the following:

http://localhost/myapp/packages/index/page:3

Query string parameters will generate a URL, which instead looks like this:

http://localhost...