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 回答