public function actionUserinfoUpdate($id = 0) { if (!($resutl = $this->_validUserRequest($id))) { $this->redirect(array('user/view', 'id' => $id)); } $model = new Userinfo(); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='userinfo-UserinfoUpdate-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ if (isset($_POST['Userinfo'])) { try { $model = Userinfo::model()->with('userRel')->findByPk(Yii::app()->getId()); if ($model == NULL) { $model = new Userinfo(); $model->attributes = $_POST['Userinfo']; } else { $model->attributes = $_POST['Userinfo']; } if ($model->save()) { $this->render('view', array('model' => $model)); } else { $this->render('UserinfoUpdate', array('model' => $model)); } //echo '<pre>'; var_dump($model); echo '</pre>'; die(); } catch (Exception $e) { throw new CHttpException(404, 'The requested page does not exist.'); } } $this->render('UserinfoUpdate', array('model' => $model)); }
public function loadModelByUserId($id) { $model = Userinfo::model()->findByAttributes(array('user_id' => $id)); //throw new CHttpException(404,'The requested page does not exist.'); return $model; }
/** * 删除Use用户 * @param $UID */ public function actionUsedelete($UID = null) { if (!empty($UID)) { if (Account::model()->deleteByPk($UID)) { if (Userinfo::model()->deleteAll('accountId=:UID', array(":UID" => $UID))) { Yii::app()->user->setFlash('Flash_role', '删除用户及相关信息成功!'); } else { Yii::app()->user->setFlash('Flash_role', '删除用户及相关信息失败!'); } } } $this->redirect($this->createUrl('System/Setuser&roleId=' . $_GET['roleId'])); }