Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i count the review so that i can display according to popularity.i.e who has heigst review show first and so on.which venue has higest review it will show first and then the rests are.I have tried it but its not working plz help me..
Below is my coding

VB
Array
(
    [0] => Array
        (
            [Venue] => Array
                (
                    [id] => 6

                )


            [Review] => Array
                (
                    [0] => Array
                        (
                            [id] => 9
                            [rating] => 4
                            [venue_id] => 6
                        )

                    [1] => Array
                        (
                            [id] => 10
                            [rating] => 3
                            [venue_id] => 6
                        )

                    [2] => Array
                        (
                            [id] => 11
                            [rating] => 3
                            [venue_id] => 6
                        )

                )



        )

    [1] => Array
        (
            [Venue] => Array
                (
                    [id] => 15

                )



            [Review] => Array
                (
                    [0] => Array
                        (
                            [id] => 16
                            [rating] => 5
                            [venue_id] => 15
                        )

                    [1] => Array
                        (
                            [id] => 17
                            [rating] => 4
                            [venue_id] => 15
                        )

                )


        )

    [2] => Array
        (
            [Venue] => Array
                (
                    [id] => 17

                )


            [Review] => Array
                (
                    [0] => Array
                        (
                            [id] => 15
                            [rating] => 4
                            [venue_id] => 17
                        )

                )

        )



    [3] => Array
        (
            [Venue] => Array
                (
                    [id] => 31

                )



            [Review] => Array
                (
                )



        )

    [4] => Array
        (
            [Venue] => Array
                (
                    [id] => 32

                )


            [Review] => Array
                (
                    [0] => Array
                        (
                            [id] => 18
                            [rating] => 1
                            [venue_id] => 32
                        )

                    [1] => Array
                        (
                            [id] => 19
                            [rating] => 1
                            [venue_id] => 32
                        )

                    [2] => Array
                        (
                            [id] => 20
                            [rating] => 1
                            [venue_id] => 32
                        )

                    [3] => Array
                        (
                            [id] => 21
                            [rating] => 1
                            [venue_id] => 32
                        )

                    [4] => Array
                        (
                            [id] => 22
                            [rating] => 1
                            [venue_id] => 32
                        )

                )

        )

)



PHP
if ($order == 'popularity') {
         $order = array('COUNT(Review) DESC');
     }
     $this->Paginator->settings = array('conditions' => $conditions, 'limit' => 10, 'order' => $order, 'page' => @$data['page']);
     $sqql = $this->Paginator->paginate('Venue');
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900