/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Tucao the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Tucao::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionOppose() { if (!Yii::app()->request->isPostRequest) { echo 'failed'; die; } $tucao_id = $_POST['tucao_id']; $model = Tucao::model()->findByPk($tucao_id); $model->oppose++; $model->save() or die(' 保存失败'); echo 'success'; }