Here is a piece of my code
$file=Files::model()->findByPk($id);
if($file == null) {
throw new CHttpException(404,'Not found');
}
$count = $file->count;
$count++;
$file->count = $count;
$file->save();
$this->redirect(Yii::app()->request->hostInfo."/".$file->path);
The Files model contains a count field.
The code is ok, and there are no warnings, but the save method is not working.
try
$file->getErrors()to display after save() and before redirect to see if there are no errorsthis would show you what is the problem. Most common is you are not populating the dependencies required for a model to insert a row in database
to see it in well format use