1

I try to use the paginate class into CakePhp having the query results created by a custom method and not in the traditional CakePHP way .

At the end i have an array.

I try to apply the paginate into this array but did not see it paginating :

$myArray = $this->myModel->SearchDatabaseData( ); $myArray = $this->paginate('myModel');

The query is made into a Component so it claims for a Model instance instead PaginatorComponent::validateSort() must be an instance of Model, instance of VerificacaoComponent given

Can i apply CakePHP pagination into a custom made array ?

I am using CakePhp 2.5.

1 Answer 1

1

You need to use Cakephp Custom query pagination. This requires 2 functions in your model, one with the query it self and another one with a count query with the same conditions.

When you try to paginate in your model, CakePhp has 2 global functions in the main AppModel, basically you will override this 2 functions rewriting them in your model.

This functions are: paginate() and paginateCount()

Once you override the AppModel functions with your custom version in your model, you can use regular $this->YourModelName->paginate(); in your controller.

You can find examples in this StackOverflow question: Custom Query Pagination Cakephp

You can check the original documentation here: http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html#custom-query-pagination

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.