Пример #1
0
 }
 //     $existeSystemId = $em->createQuery('SELECT u FROM App\Model\User u WHERE u.system_id = '.$systemId);
 $existSystemId = $em->getRepository('App\\Model\\User')->findOneBy(array('system_id' => $systemId));
 if ($existSystemId) {
     $app->response->headers->set('Content-Type', 'application/json');
     echo Util::resPonseJson($app, 4001, "User has existed", array());
     exit;
 }
 $user = new User();
 $user->setSystem_id($systemId);
 $user->setUsername($username);
 $user->setPassword_hash(password_hash($password, PASSWORD_BCRYPT));
 $user->setBirthday(strtotime($birthday));
 $user->setHome_town($home_town);
 $user->setId_number($id_number);
 $user->setNation($nation);
 $user->setPhone($phone);
 $user->setInviter($inviter);
 $user->setSex($sex);
 $user->setStatus(1);
 $user->setCreated_at(time());
 $user->setUpdated_at(time());
 $user->setPayment_password("");
 try {
     $em->persist($user);
     $em->flush();
 } catch (Execption $e) {
     $app->response->headers->set('Content-Type', 'application/json');
     echo Util::resPonseJson($app, 500, "System error", array());
     exit;
 }