コード例 #1
0
 public function actionUpdateAccount($id_user = null)
 {
     $model = new Account();
     if ($id_user) {
         $account = User::findIdentity($id_user)->findAccount();
         //var_dump($user->username);die;
     } else {
         $account = Yii::$app->user->identity->findAccount();
         if (Yii::$app->session->get('account') == null) {
             Yii::$app->session->set('account', Yii::$app->user->findAccount());
         }
     }
     if ($model->load(Yii::$app->request->post() && $model->validate())) {
     } else {
         return $this->render('update-account', ['model' => $model, 'account' => $account]);
     }
 }
コード例 #2
0
 /**
  * Creates a new Account model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Account();
     if ($model->load(Yii::$app->request->post())) {
         $a = $model->acct_name;
         $connection = \Yii::$app->db;
         $sql = $connection->createCommand('SELECT  acct_name  FROM Account WHERE acct_name = "' . $a . '"')->queryAll();
         if ($sql != null) {
             echo "<SCRIPT LANGUAGE='JavaScript'>\n\t\t\t\t\t\twindow.alert('This Account has already existing')\n\t\t\t\t\t\twindow.location.href='index.php?r=project%2Findex';\n\t\t\t\t\t\t</SCRIPT>";
         } else {
             $model->save();
             return $this->redirect(['project/index']);
         }
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
     //echo "<a href='index.php?r=project%2Findex'> Go Back</a>";
 }