How to Limit the paginate in cakephp

You can set conditions for the pagination.

function listRecords()
  {
  $this->paginate = array(
    'conditions' => array('Model.id >=' => 50, 'Model.id <=' => 75),
    'limit' => 5
    );
  $this->paginate('Model');
  );

EDIT:

A solution from here:

$this->paginate = array(
  'limit' => 20,
  'totallimit' => 1000
  );

And then in the Model:

public function paginateCount($conditions = null, $recursive = 0, $extra = array())
  {
  if( isset($extra['totallimit']) ) return $extra['totallimit'];
  }

Improved version with reference of: http://www.mainelydesign.com/blog/view/best-paginatecount-cakephp-with-group-by-support

This return the correct total count base on whichever is less.

public function paginateCount($conditions = null, $recursive = 0, $extra = array()) 
    {
        $conditions = compact('conditions');
        if ($recursive != $this->recursive) {
            $conditions['recursive'] = $recursive;
        }
        unset( $extra['contain'] );
        $count = $this->find('count', array_merge($conditions, $extra));

        if (isset($extra['group'])) {
            $count = $this->getAffectedRows();
        }

        if (isset($extra['totallimit']) && $extra['totallimit'] < $count) {
            return $extra['totallimit'];
        }

        return $count;
    }