Latest Comment On Top

Hi,

I am having comments page and lists the page in Clistview (using comments\index.php).

I want the latest comments to appear on top rather than at the bottom of the page.

Thanks in advance.

You need to add an order clause to the criteria you’re using to get the data from the database.

I have used the order clause and now i am able to view the latest comment.

Thanks

is there any way to display the comments only of current date’s

Try using CDbExpression. In MySQL you could use something like:




$criteria->addCondition(new CDbExpression('DATE(col_name) = CURDATE()'));



Realistically, you should probably look into setting this up in a named scope.

Hi,

I have used the below code and it worked,




public function actionIndex()  

        {  

                $dataProvider=new CActiveDataProvider('Comment' ,array(    

                        'criteria'=>(array(    

                                'condition'=>'DATE(your date field) = CURDATE()',  

                                'order'=>'your date field DESC',  

                                )    

                        )    

                        ));