gpt4 book ai didi

php - cakePHP 在没有 session 、序列化或发布的情况下使用发布数据进行分页以获取

转载 作者:可可西里 更新时间:2023-11-01 13:48:42 26 4
gpt4 key购买 nike

我在 Controller /索引中创建了一个带有 POST 操作的小型搜索和过滤表单,它向自身 POST 条件和要分页的字段 ($this->paginate($conditions))。

这对第一页很好,但是在后续页面上过滤条件丢失了。分页 passedArgs 很好地支持 GET 变量。

有没有一种简单的方法可以将 POST 条件传递给其他分页页面?

我看过的方法是通过 session 传递 $conditions,这并非没有分配 session 和再次提交表单时取消设置 session 的复杂性(对用户过滤条件)。另一种方法是将 $conditions 作为序列化字符串传递给 url_encode 作为 GET 参数。

有没有像 passedArgs 这样的好方法来做到这一点。 session 和 url_encode 看起来不像蛋糕样式。

谢谢

最佳答案

Is there an un complex way to pass the post conditions to the other paginated pages?

没有。

Is there an good cake way to do this more like passArgs, sessions and url encode do not look like cake style.

只有一种方法,不管是蛋糕还是不是蛋糕。

  1. 必须使用 GET 方法进行搜索。

  2. 通过查询字符串传递的参数。

因此,使用 method="GET"创建您的搜索表单,然后使用 http_build_query() 组合查询字符串并使用它建立到其他页面的链接。

有点好奇,你可以在 SO 上看到一个例子:

http://stackoverflow.com/questions/tagged?tagnames=php&page=5&sort=newest&pagesize=50

关于php - cakePHP 在没有 session 、序列化或发布的情况下使用发布数据进行分页以获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2927209/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com