예제 #1
0
 /**
  *认证复原,status改为0,需重新认证
  * @param int $user_id
  *
  */
 public function certInit($user_id)
 {
     $tables = $this->certTable;
     $m = '';
     foreach ($tables as $val) {
         $m = new M($val);
         $res = $m->data(array('status' => self::CERT_INIT))->where(array('user_id' => $user_id))->update();
         if ($res === false) {
             //更新失败,后续不再更新
             break;
         }
     }
     if (is_object($m)) {
         $m->commit();
     }
 }
예제 #2
0
파일: User.php 프로젝트: weipinglee/nn2
 /**
  * 企业用户信息更新
  * @param array $userData 用户数据
  * @param array $companyData 企业数据
  */
 public function companyUpdate($userData, $companyData)
 {
     $user = new M('user');
     if ($user->data($userData)->validate($this->userRules, 2) && $user->validate($this->companyRules, $companyData, 2)) {
         $user_id = $userData['user_id'];
         if ($this->existUser(array('id' => array('neq', $user_id), 'username' => $userData['username']))) {
             return $this->getSuccInfo(0, '用户名已注册');
         }
         $user->beginTrans();
         unset($userData['user_id']);
         if (($res1 = $user->where(array('id' => $user_id))->data($userData)->update()) !== false) {
             $res2 = $user->table('company_info')->where(array('user_id' => $user_id))->data($companyData)->update();
         }
         if (false !== $res1 && isset($res2) && false !== $res2) {
             //操作成功
             if ($res1 === 0 && $res2 === 0) {
                 //更新成功,但数据未改变
                 $user->commit();
                 $res = 2;
             } else {
                 $res = 1;
             }
             //此时事务不提交,后续还要更新认证状态
         } else {
             $res = '系统繁忙,请稍后再试';
         }
         //$res = $user->commit();
     } else {
         $res = $user->getError();
     }
     if (is_numeric($res)) {
         //操作成功
         return $this->getSuccInfo($res);
     } else {
         return $this->getSuccInfo(0, $res);
     }
 }