0

私が以下を実行するとき:

$popular_posts = $this->Blog->find('all', array('limit' => 5));

私は次のようになります:

配列

(
    [0] => Array
        (
            [Blog] => Array
                (
                    [id] => 4fcfb37d-3eb0-4ec2-a744-175c987a2b72
                    [title] => This is a post example2
                    [short_description] => You've stumbled across our blog! Welcome! Here 
                    [created] => 2012-06-06 21:46:05
                    [modified] => 2012-06-07 16:01:24
                )

            [Reply] => Array
                (
                    [0] => Array
                        (
                            [id] => 4fcfb305-0c58-421b-9149-175c987a2b72
                        )

                    [1] => Array
                        (
                            [id] => 4fd0ae9e-dca0-4afe-862c-1258987a2b72
                        )

                )

        ),
    [1] ...
    [2] ...

)

返信の数で結果を並べ替えるにはどうすればよいですか?(説明)?

4

1 に答える 1

0

これを試して

$data = $this->Blog->find('all',array('group' =>array('Reply.id'), 
                        'order' => array('COUNT(Reply.id) DESC'),
                        'limit'=> 5)); 
于 2012-06-12T17:16:02.263 に答える