示例#1
0
 public function actionUpdate()
 {
     $data = Yii::app()->request->getRestParams();
     $newTask = Todos::model()->findByPk((int) $data['id']);
     $newTask->status = $data['status'];
     if (!$newTask->validate()) {
         $this->_sendResponse(400, 'Error: the model is bad');
     }
     if ($newTask->save()) {
         $this->_sendResponse(200, CJSON::encode($newTask));
     } else {
         $this->_sendResponse(500, 'Error: the model is not saved');
     }
 }