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'=>$dataProvider,
'itemView'=>'_view',
'separator'=>'<div class="separator"></div>',
)); ?>[/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!