I am using data table inbuilt ajax custom pagination.
Here i need to pass 2 parameter in limit function .
I need some help to make it possible .I am using cakephp 3.2.
Below is my code.
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";
This code is in core php ,
I want to convert it into cakephp .
Below is what i have tried so far.
$order=$requestData['order'][0]['dir']; //descending ya ascending
$id=$columns[$requestData['order'][0]['column']];///order by which column
$query= $this->Orders->find('all')->where($condition)->limit($requestData['length'])->order(['Orders.'. $id.' '.$order]);
How can i write this code LIMIT ".$requestData['start']." ,".$requestData['length']." ";
Using cakephp ,
In limit how to give both the limit as well as the start parameter($requestData['start']).
Eventually ,this is the end of my problem. Thank you any suggestion will be highly appreciated.
In Limit, it supports two parameters if you pass only one then it is limit parameter, and offset is 0 by default
LIMIT 10 //returns first 10 records only
If you pass two parameters then first is offset and second is limit
LIMIT 50, 10 //returns 10 records from 51st record
for passing offset in CakePHP query you can use offset($start)
method or page($page_number)
method Check DOC
Your Code Should be
$query= $this->Orders->find('all')->where($condition)->limit($requestData['length'])->offset($requestData['start'])->order(['Orders.'. $id.' '.$order]);