CakePHP: paginating, sorting, filtering data from

2019-08-01 16:30发布

I'm trying to use Cake's native caching methodes to cache some data that I will need to paginate, sort andfiler (search) - that's why I'm caching data arrays, not views or paginated arrays/views. As far as I can see searching/filtering components and Paginator only ask the database, which is what I don't want. Is there any way I could put these together in Cake? Thanks in advance for any answer.

1条回答
相关推荐>>
2楼-- · 2019-08-01 16:53

You're correct to assume that Cake always expects a database result to paginate. One of the easiest solutions is refactoring a class like this one into a helper (for the pagination) or a component (for filtering) and feed the helper/component your data arrays (more info on custom helpers and components). The only downside to this is that your application has to read the cached arrays into memory before creating a paginated result set.

There's also this article, but I'm not sure if applies to your setup.

Another option might be to write your own datasource for cached data arrays, but Cake's documentation on this is a little meagre. I've dabbled in the creation of a datasource for some custom XML feeds, but never got around to adding pagination. From the third-party datasources floating around I'm not sure if it's even possible.

查看更多
登录 后发表回答