Question

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?

Was it helpful?

Solution 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.

OTHER TIPS

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top