public function actionTestApply() { if (!Yii::app()->user->isGuest) { $model = Apply::model()->findByPk($_POST['product_id']); if (isset($_POST['LEMONCMS_CSRF_TOKEN'])) { $model->test_text = $_POST['test_text']; $model->img = $_POST['img']; if ($model->save()) { $this->redirect(array('user/apply')); } } } else { $this->render("error"); } }
Can print out $model->test_text $model->img
public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('user_id, product_id', 'required'), array('user_id, product_id', 'numerical', 'integerOnly'=>true), array('insert_time', 'safe'), // The following rule is used by search(). // @todo Please remove those attributes that should not be searched. array('id, user_id, insert_time, product_id', 'safe', 'on'=>'search'), ); }
This is the database
It was written by someone else.
Reply content:
public function actionTestApply() { if (!Yii::app()->user->isGuest) { $model = Apply::model()->findByPk($_POST['product_id']); if (isset($_POST['LEMONCMS_CSRF_TOKEN'])) { $model->test_text = $_POST['test_text']; $model->img = $_POST['img']; if ($model->save()) { $this->redirect(array('user/apply')); } } } else { $this->render("error"); } }
Can print out $model->test_text $model->img
public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('user_id, product_id', 'required'), array('user_id, product_id', 'numerical', 'integerOnly'=>true), array('insert_time', 'safe'), // The following rule is used by search(). // @todo Please remove those attributes that should not be searched. array('id, user_id, insert_time, product_id', 'safe', 'on'=>'search'), ); }
This is the database
It was written by someone else.
phpif ($model->save()) { $this->redirect(array('user/apply')); }
This paragraph I used to write
phpif (!$model->save()) { dump($model->errors);}$this->redirect(['user/apply']);
So if it doesn't work, save it prints out the wrong thing.