Clistview And Mysql Functions

Hi everybody,

I’m new on Yii Framework and I’m trying to do something that should be easy, but it takes me too long to find something out.

I have the following code in my controller:

   [color="#2E8B57"] $criteria=new CDbCriteria(array(


        //'condition'=>'status='.Post::STATUS_PUBLISHED,


		[color="#FF0000"]'select'=>'id, title, content, DAYOFMONTH(creation_date) as day',[/color]


        'order'=>'creation_date DESC',


        'with'=>'commentCount',


    ));





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


        'pagination'=>array(


            'pageSize'=>5,


        ),


        'criteria'=>$criteria,


		


	));


	


	$this->render('index',array(


		'dataProvider'=>$dataProvider,


	));[/color]

And the following in my index view:

[color="#2E8B57"]<?php $this->widget(‘zii.widgets.CListView’, array(

'dataProvider'=&gt;&#036;dataProvider,


'itemView'=&gt;'_view',


'separator'=&gt;'&lt;div class=&quot;separator&quot;&gt;&lt;/div&gt;',

)); ?>[/color]

I want to use a MySql funtion into my query as is in the red line, the problem is that I get this error “Property “Post.day” is not defined.” Obviously, my db table ‘Post’ has no day as column, it’s just the alias.

I have no idea how I can make this works, it’s making me desesperate!

Thanks in advance!

Dear menxaca

In your Post model,declare a virtual property.




public $day;



Regards.

Thanks seenivasan!!!

It works! I’m a begginner on this, I have been like 2 days trying to figure something out, thanks again! I really appreciate your answer because if not… who knows how much time I had spent on this!

PS: sorry for my English…