We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Pagination for ODM Collection

So I have following problem. I wanted to use Phalcon\Paginator\Adapter\Model with an implementation of Phalcon\Mvc\Collection but since collections find method returns a native array instead of Phalcon\Mvc\Model\Resultset the whole thing kind of breaks. Let's assume I have a huge collection and do not want to load the all the results into memory. Do you have any suggestions on how to solve this problem?

Thanks in advance for your answers!

I was thinking about something along these lines could solve the problem:


Of course it is limited, since the find method is inside the pagination. It would be also nice to wrap the array being returned into an iterator, that would call toArray on collection, while iterating through it.