I have a question regarding the Paginator Component of CakePHP3 (3.0.13). I'm using the MYSQL function FIELD() to order my data, like that:
$this->paginate = array_merge_recursive([
'conditions' => [
'zip IN' => $zips
],
'order' => [
'FIELD(zip, '.rtrim(implode(',', $zips), ',').')',
'ispro' => 'desc',
],
$this->paginate
]);
When I apply this to my $this->paginate() it wouldn't be recognized as long as the query param sort is set. To avoid this I remove the sort in my request with:
if (isset($this->request->query['sort'])) {
unset($this->request->query['sort']);
}
This is working, but I was wondering if there is a better solution, maybe in the paginator component itself, which I haven't found yet.
$this->paginate('sortWhitelist' =>[ 'zip']);? Already tried that, but it wouldn't work. - Seb$this->paginate('sortWhitelist' =>[ 'FIELD(zip, '.rtrim(implode(',', $zips), ',').')'])- arilia