Ejemplo n.º 1
0
 public function actionTest()
 {
     $model = new Test();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         Yii::$app->session->setFlash('success', 'yeap!');
     }
     return $this->render('test', array('model' => $model));
 }
Ejemplo n.º 2
0
 public function actionInsert()
 {
     //Test->实例obj对象->save方法转化为数据->db
     $test = new Test();
     $test->id = 'bbbb';
     $test->title = "*****@*****.**";
     $test->validate();
     if ($test->hasErrors()) {
         echo 'error';
         die;
     }
     $test->save();
 }