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

Learn More

Implement pagination on a CakePHP project

2481 Runs 11902 Views 6206 Copies
Saved

Saved

tjpotts5 1

tjpotts5
published 4 years ago

<?php

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));
    }
    
    parent::__construct();
  }
}
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).