0
votes

i have a cakephp function in my model that calls a stored procedure that returns a resultset, how do i paginate the resultset in my controller? here is the function in my model

public function GetSummary(){
     $sql="CALL main_report()";
     return $this->query($sql);
  }

and this is how am accessing the data in my controller

$usagesummary=$this->Book->GetSummary();

how do i paginate this data?

1

1 Answers

0
votes

Make yourself this question: Can the store procedure be done with core Cake model? if yes, you better do it that way.

If not, then you will need to implement a custom paginator, that means you will have to implement the paginate() and paginateCount() methods on your model

Another thing you can do is to create a custom find type as described here. If you take this path, and let's say you named your custom find "summary", then you will paginate this way

public $paginate = array(
    'findType' => 'summary'
);

What I said is just a small summary of what you can find in the official documentation