Show Published Post And Approved Comment at RecentComments List

I used yii blog from Yii Framework

I want Show Only Published Post And Approved Comment at RecentComments List

I used This code at Comment Model


public function findRecentComments($limit=10)

{

    return $this->with('post')->findAll(array(

        'condition'=>'t.status='.self::STATUS_APPROVED.'status='.Post::STATUS_PUBLISHED,

        'order'=>'t.create_time DESC',

        'limit'=>$limit,

    ));

}

But Show All Post And Approved Comment in RecentComments List

I want Show Published Post And Approved Comment at RecentComments List

PLease Help Me

Maybe it’s just me, but you seem to have an SQL syntax error in your ‘condition’ line.

I rewrote your method like this:




public function findRecentComments($limit=10)

{

	return $this->with('post')->findAll(array(

	 	'condition'=>'t.status=:approved AND post.status=:published',

	 	'params'=>array(

	 	 	':approved'=>self::STATUS_APPROVED,

	 	 	':published'=>Post::STATUS_PUBLISHED

	 	),

	 	'order'=>'t.create_time DESC',

	 	'limit'=>$limit,

	));

}