I don't succeed in using the pagination with a custom query. I follow exactly what's in the doc, but it doesn't work. The point is to paginate a list of records, having the flag 'valid' to 'Y' or 'N'.
In the controller:
if (!isset($this->request->query['valid']) || $this->request->query['valid'] == '')
$allFilters['valid'] = 'N';
else
$allFilters['valid'] = 'Y';
$this->paginate = ['finder' => ['curnames' => $allFilters]];
$data = $this->paginate($this->Names)->toArray();
In the model:
public $paginate = ['finder' => 'curnames', 'limit' => 25, 'order' => ['Names.id' => 'asc']];
public function findCurnames(Query $query, array $options) {
$query->where([
'valid' => $option['valid']
]);
return $query;
}
When I execute the code, I get a Cake\Network\Exception\NotFoundException
exception. What I am missing?
Update: The version is 3.3. The error is triggered when this is executed:
$data = $this->paginate($this->Names)->toArray();
Update : In the controller, I've change the line
$this->paginate = ['finder' => ['curnames' => $allFilters]];
to
$paginate = ['finder' => ['curnames' => $allFilters]];
and the error doesn't pop up anymore. But the condition filtering on the 'valid'='Y' or 'N' is not taken into account. So it still doesn't work.