Speed up development with full-stack environments for every branch.

Learn More

Implement pagination on a CakePHP project

2519 Runs 12146 Views 6272 Copies


tjpotts5 1

published 4 years ago


App::uses('AppModel', 'Model');

/* This model uses the Arraysource plugin to provide data from an array in
    memory rather than a database, for simplicity. */

class SomeData extends AppModel {
  public $name = 'SomeData';
  public $displayField = 'text';
  public $records;
  function __construct() {
    /* When the class is constructed, initialize the data array
      and fill it with some dummy data */
    $this->records = array();
    for ($n = 1; $n <= 100; $n++) {
      array_push($this->records, array('id' => $n, 'text' => 'Item ' . $n));
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).