浏览代码

Merge branch 'test' of git.oschina.net:yiguanjia/php into test

seam 8 年之前
父节点
当前提交
cec8511745
共有 1 个文件被更改,包括 25 次插入10 次删除
  1. 25 10
      www/protected/modules/moonclub/controllers/UserController.php

+ 25 - 10
www/protected/modules/moonclub/controllers/UserController.php

@@ -37,16 +37,31 @@ class  UserController extends MoonClubBaseController{
                 $address = Yii::app()->getRequest()->getParam('address','');
                 $address = Yii::app()->getRequest()->getParam('address','');
                 $time = Yii::app()->getRequest()->getParam('time');
                 $time = Yii::app()->getRequest()->getParam('time');
                 $register_time = time();
                 $register_time = time();
-                $userInfo = new UserInfo;
-                $userInfo->user_id = $user->_id;
-                $userInfo->user_name = $user_name;
-                $userInfo->time = $time;
-                $userInfo->sex = $sex;
-                $userInfo->card_id = $card_id;
-                $userInfo->mobile = $mobile;
-                $userInfo->address = $address;
-                $userInfo->register_time = $register_time;
-                $result = $userInfo->save();
+                $criteria = new EMongoCriteria();
+                $criteria->user_id('==',$user->_id);
+                $tmp = UserInfo::model()->findAll($criteria);
+                if ($tmp) {
+                    $tmp->user_id = $user->_id;
+                    $tmp->user_name = $user_name;
+                    $tmp->time = $time;
+                    $tmp->sex = $sex;
+                    $tmp->card_id = $card_id;
+                    $tmp->mobile = $mobile;
+                    $tmp->address = $address;
+                    $result = $tmp->save();
+                } else {
+                    $userInfo = new UserInfo;
+                    $userInfo->user_id = $user->_id;
+                    $userInfo->user_name = $user_name;
+                    $userInfo->time = $time;
+                    $userInfo->sex = $sex;
+                    $userInfo->card_id = $card_id;
+                    $userInfo->mobile = $mobile;
+                    $userInfo->address = $address;
+                    $userInfo->register_time = $register_time;
+                    $result = $userInfo->save();
+                }
+
                 CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$result);
                 CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$result);
             } else {
             } else {
                 CommonFn::requestAjax(false,CommonFn::getMessage('message','id_not_exits'));
                 CommonFn::requestAjax(false,CommonFn::getMessage('message','id_not_exits'));