コード例 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     // echo "masuk";
     $this->layout = " ";
     $model = new BlogComment();
     $model->datetime = date('Y-m-d H:i:s');
     $model->name = $_REQUEST['name'];
     $model->comment = $_REQUEST['comment'];
     $model->blog_id = $_REQUEST['blog_id'];
     if ($model->save()) {
         $this->redirect(array('blog/view', 'id' => $_REQUEST['blog_id']));
     } else {
         print_r($model->getErrors());
     }
     // // Uncomment the following line if AJAX validation is needed
     // // $this->performAjaxValidation($model);
     // if(isset($_POST['BlogComment']))
     // {
     // 	$model->attributes=$_POST['BlogComment'];
     // 	if($model->save())
     // 		$this->redirect(array('view','id'=>$model->id));
     // }
     // $this->render('create',array(
     // 	'model'=>$model,
     // ));
 }
コード例 #2
0
ファイル: BlogController.php プロジェクト: Dvionst/vvfy
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionAddcomment()
 {
     $this->layout = " ";
     $model = new BlogComment();
     $model->datetime = date('Y-m-d H:i:s');
     $model->name = $_REQUEST['name'];
     $model->comment = $_REQUEST['comment'];
     $model->blog_id = $_REQUEST['blog_id'];
     if ($model->save()) {
         $this->redirect(array('blog/view', 'id' => $_REQUEST['blog_id']));
     } else {
         print_r($model->getErrors());
     }
 }