Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP Pagination order not working

Tags:

cakephp

I am using cakephp V2.0.2

I am having trouble with

$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
            );

Everything works all fields, joins, group, limits no problem but the ordering simple wont work. Outputting the sql_dump element shows that it is never added to the query.

Any help would be greatly appreciated.

Thanks

like image 756
Gabriel Spiteri Avatar asked Oct 23 '12 13:10

Gabriel Spiteri


1 Answers

By doing

"order" =>  "Player.join_country DESC" 

Worked for me.

I hope it helps you too.

like image 100
XuDing Avatar answered Nov 24 '22 18:11

XuDing