I have a calendar app in Yii where I store events for each user. I would like to dynamically create a title for each event.
This code is in my controller:
$criteria = new CDbCriteria; $criteria->select = array('all_day','end','id','start'); $criteria->condition = 'user_id ='.$user->id; $events = Calendar::model()->findAll($criteria); foreach($events as $event) { $event->title = 'test title'; } echo CJSON::encode($events);
In my Calendar model, I added a new property called $ title:
public $title;
But then when I go to the JSON echo, the header is not displayed ...
[{"all_day":false,"end":"-948712553","id":"2","start":"-146154706"}]
What do I need to do to add a header to the JSON result set?
ews2001
source share