CakePHP分页命令不起作用

时间:2012-10-23 13:01:57

标签: cakephp

我正在使用cakephp V2.0.2

我遇到了麻烦

$this->paginate = array(
                "fields" => array(
                    "Player.join_country"
                ),
                "joins" => array(
                    array(
                        "table" => "banner_key_current_ext",
                        "alias" => "BannerKeyCurrentExt",
                        "type" => "inner",
                        "conditions" => "BannerKeyCurrentExt.banner_key_id = BannerKeyCurrent.banner_key_id"
                    ),
                    array(
                        "table" => "players",
                        "alias" => "Player",
                        "type" => "inner",
                        "conditions" => "BannerKeyCurrentExt.identifier = Player.zban_player_id" . $country_condition
                    ),
                    array(
                        "table" => "users",
                        "alias" => "User",
                        "type" => "inner",
                        "conditions" => "BannerKeyCurrent.user_id = User.user_id"
                    ),
                    array(
                        "table" => "tag_links",
                        "alias" => "TagLinks",
                        "type" => "inner",
                        "conditions" => "TagLinks.id = BannerKeyCurrent.user_id AND TagLinks.tag_id = 710"
                    )
                ),
                "conditions" => array(
                    "BannerKeyCurrent.date BETWEEN ? AND ?" => array(
                        $this->request->query["period_from"],
                        $this->request->query["period_to"]
                    ),
                    "BannerKeyCurrent.plan_id" => $brands_plan_map[$this->request->query["brand"]]["plans"],
                    "BannerKeyCurrent.operation_id" => $operation_ids
                ),
                "group" => array( "Player.join_country" ),
                "order" => array(
                    "Player.join_country" => "DESC"
                ),
                "limit" => 999999,
                "maxLimit" => 999999
            );

一切都适用于所有领域,联接,组,限制没有问题,但订单简单不会工作。输出sql_dump元素表明它永远不会添加到查询中。

非常感谢任何帮助。

由于

3 个答案:

答案 0 :(得分:9)

通过

"order" =>  "Player.join_country DESC" 

为我工作。

我希望它对你有帮助。

答案 1 :(得分:0)

尝试:

$this->Paginator->settings = array(
    "fields" => array(
                "Player.join_country"
            ),
            "joins" => array(
                array(
                    "table" => "b...

$pagedResults = $this->paginate('YourModel');

答案 2 :(得分:0)

网址中的参数是否有任何分页顺序?

Paginator将在查询中覆盖任何在url中指定的任何顺序(因此排序列标题可以工作)。

如果order参数引用了无效字段,那么在从查询中删除您的订单之后,蛋糕会忽略它,并准备在网址中添加该字段。