In the controller for the view…
$topic->topic_views = new CDbExpression('topic_views + 1');
$topic->saveAttributes(array('topic_views'=>$topic->topic_views));
Hope this helps someone and it’s not terrible code.
In the controller for the view…
$topic->topic_views = new CDbExpression('topic_views + 1');
$topic->saveAttributes(array('topic_views'=>$topic->topic_views));
Hope this helps someone and it’s not terrible code.
Hmm. Why not use the updateCounters() method? Or - if you already have fetched the record:
$topic->topic_views++;
$topic->save();