public function actionRemoveCaption() { if (!Yii::app()->request->isAjaxRequest) { Yii::app()->end(); } if (isset($_GET['caption_id']) && isset($_GET['slide_id'])) { $caption = Caption::model()->findByPk($_GET['caption_id']); if ($caption !== NULL) { $caption->delete(); echo CJSON::encode(array('status' => 'success')); Yii::app()->end(); } } echo CJSON::encode(array('status' => 'error')); Yii::app()->end(); }
/** * 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 Caption the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Caption::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }