How To Display Those Posts On Which Most Comments Are Posted

I want to display at least top 4 posts on which most comments are posted.

I have POST and COMMENTS relation using

Post.php model




public function relations() {

        return array(

            'comments' => array(self::HAS_MANY, 'Comment', 'post_id'),

            'category' => array(self::BELONGS_TO, 'Category', 'category_id'),

            'commentCount' => array(self::STAT, 'Comment', 'post_id', 'condition'=>'status=2'),

        );

    }



and Comment.php model




public function relations()

	{

		return array(

			'post' => array(self::BELONGS_TO, 'Post', 'post_id'),

		);

	}



and I want to display here in view just like below




<div class="tab-pane fade in active" id="month">

                <div class="list-group more-last-link">

                    <?php

                    $cmd = Yii::app()->db->createCommand();

                    $cmd->select = '*';

                    $cmd->from = 'post';

                    $cmd->where = '`create_time` >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';

                    $cmd->limit = '4';

                    $cmd->order = 'views DESC';

                    $monthdownload = $cmd->query();

                    foreach ($monthdownload as $data) {

                        ?>

                    <a href="#" class="list-group-item">

                        <i class="fa fa-link"></i> <?php echo $data['title']; ?>

                    </a>

                    <?php } ?>

                </div>

            </div>



I did the above settings for mostly viewed posts.

Now I want to use the idea for those posts on which mosts comments are passed.

Thanks in advance.