سؤال

I've got some wierd problem with Pagination, the code:

$this->Paginator->settings = array(
    'Visit' => array(
        'limit' => 10
    )
);
$visits = $this->Paginator->paginate('Visit');
echo count($visits);

And count give me: page 1 = 0, page 2 = 6, page 3 = 10, page 4 = 7, ... Why? I thought that paginator id doing something like:

SELECT * FROM visits LIMIT 10 OFFSET pageNumber

I've got 4 realtions with visits table, maybe this is an issue?

هل كانت مفيدة؟

المحلول 2

I found it. Someone was deleting from return some elements by afterFind function in AppModel class. I checked VisitModell class but didnt check upclass, damn... so stupid. So sorry for wasting your time.

نصائح أخرى

try this

$this->paginate = array('conditions'=>array(
    'all conditions'...,
    ),
    'limit' => 10,
    'recursive'=> 0 or -1
));
$this->Paginator->settings = $this->paginate;
$visits = $this->Paginator->paginate('Visit');
echo count($visits);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top