Ejemplo n.º 1
0
 public function updateUser($uid, $data)
 {
     //检查参数
     if (!$uid || !$data) {
         $this->apiError(400, '参数不能为空');
     }
     //将数据分配到两张表中
     $split = $this->splitUserFields($data);
     $home_user = $split['home'];
     $ucenter_user = $split['ucenter'];
     //写入数据库
     $api = new UserApi();
     if (isset($ucenter_user)) {
         $res = $api->updateUserNoPassword($uid, $ucenter_user);
         if (!$res['status']) {
             $this->apiError(0, $this->getRegisterErrorMessage($res['info']));
         }
     }
     if ($home_user) {
         $map = array();
         $model = D('Home/Member');
         if (false !== ($home_user = $model->create($home_user, 2))) {
             $result = $model->save($home_user);
             if (false === $result) {
                 $this->apiError(0, $result);
             }
         } else {
             $this->apiError(0, $this->getRegisterErrorMessage($model->getError()));
         }
     }
     //返回成功
     return $this->apiSuccess($message);
 }