当前位置: 首页>>代码示例>>PHP>>正文


PHP Player::save方法代码示例

本文整理汇总了PHP中Player::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::save方法的具体用法?PHP Player::save怎么用?PHP Player::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 function post_register()
 {
     // set validation rules for new user content.
     $rules = array('name' => 'required|min:3|max:75', 'email' => 'required|unique:users|email', 'password' => 'required|min:5|max:64');
     $v = Validator::make(Input::all(), $rules);
     if ($v->fails()) {
         return Redirect::to('user/new')->with_input('except', array('password'))->with_errors($v);
     }
     $nameArr = explode(' ', Input::get('name'), 2);
     $player = new Player();
     $player->first_name = $nameArr[0];
     $player->last_name = isset($nameArr[1]) ? $nameArr[1] : '';
     $player->save();
     if ($player->save()) {
         $user = new User();
         $user->password = Hash::make(Input::get('password'));
         $user->email = Input::get('email');
         $user->player_id = $player->id;
         if ($user->save()) {
             // log the user in the session
             Auth::login($user->id);
             return Redirect::to('user')->with('welcomeMsg', true);
         } else {
             // oh shit. roll back the player and return an error
             $player->delete();
             return Redirect::to('user/new')->with_input('except', array('password'))->with('error', 'Nah fool... something went real wrong.');
         }
     } else {
         return Redirect::to('user/new')->with_input('except', array('password'))->with('error', 'This user could not be created.');
     }
 }
开发者ID:kleitz,项目名称:brackets,代码行数:31,代码来源:home.php

示例2: post_create_player

 public function post_create_player()
 {
     if (!Request::ajax()) {
         return;
     }
     $failUri = 'bracket/players';
     // Bracket to add to.
     $bracket = Bracket::find(Session::get('bracketId'));
     // fail if bracket does not exist.
     if (!$bracket) {
         return Redirect::home();
     }
     // Make sure they gave us a player name
     $name = Input::get('playerName');
     if (!$name) {
         return Redirect::to($failUri);
     }
     // Create the new player.
     $name = explode(' ', $name);
     $player = new Player();
     $player->first_name = $name[0];
     $player->last_name = isset($name[1]) ? $name[1] : false;
     // save the player
     if ($player->save()) {
         // associate this new person with the bracket
         $bracket->players()->attach($player);
         return json_encode($player);
     } else {
         return json_encode(array());
     }
 }
开发者ID:kleitz,项目名称:brackets,代码行数:31,代码来源:bracket.php

示例3: handle_register

 public static function handle_register()
 {
     $firstname = $_POST['firstname'];
     $username = $_POST['username'];
     $password = $_POST['password'];
     $password2 = $_POST['password2'];
     $errors = array();
     if ($firstname == null) {
         $errors[] = "Syötä nimesi.";
     }
     if ($username == null) {
         $errors[] = "Syötä uusi käyttäjätunnus.";
     }
     if (Player::username_exists($username)) {
         $errors[] = "Käyttäjätunnus on jo käytössä. Valitse toinen käyttäjätunnus.";
     }
     if ($password == null || $password2 == null) {
         $errors[] = "Syötä uusi salasana.";
     }
     if ($password != $password2) {
         $errors[] = "Annetut salasanat eivät täsmänneet.";
     }
     if ($errors != null) {
         View::make('user/register.html', array('errors' => $errors, 'username' => $username, 'firstname' => $firstname));
     } else {
         // Register user/player and login
         $player = new Player(array('firstname' => $firstname, 'username' => $username, 'password' => crypt($password)));
         $player->save();
         // POST params for signing in are the same in register.html and login.html
         self::handle_login();
     }
 }
开发者ID:rryanburton,项目名称:Tsoha-Bootstrap,代码行数:32,代码来源:user_controller.php

示例4: addPlayer

 public function addPlayer($args)
 {
     $model = new Player();
     $model->setAttributes($args);
     $model->token = StringHelper::generateToken(20, 30);
     $model->created_at = new CDbExpression('NOW()');
     if ($model->save(FALSE)) {
         return $model->id;
     }
     return FALSE;
 }
开发者ID:huynt57,项目名称:quizder,代码行数:11,代码来源:Player.php

示例5: createBookedPlayer

 protected function createBookedPlayer($email, $nick, $tournament)
 {
     $player = new Player();
     $player->setFirstname("-");
     $player->setLastname("-");
     $player->setNickname($nick);
     $player->setEmail($email);
     $player->setTournament($tournament);
     $player->save();
     return $player;
 }
开发者ID:nick-keller,项目名称:sfHfLan,代码行数:11,代码来源:actions.class.php

示例6: store

 public static function store()
 {
     $params = $_POST;
     $Player = new Player(array('name' => $params['name'], 'password' => $params['password']));
     $errors = $Player->errors();
     if (count($errors) != 0) {
         View::make('/Player/new.html', array('errors' => $errors, 'player' => $Player));
     } else {
         $Player->save();
         Redirect::to('/login', array('message' => 'Pelaaja luotu! Kirjaudu nyt sisään'));
     }
 }
开发者ID:Jonharju,项目名称:Tsoha-Bootstrap,代码行数:12,代码来源:player_controller.php

示例7: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Player();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Player'])) {
         $model->attributes = $_POST['Player'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->playerId));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:first-lab,项目名称:tebing,代码行数:17,代码来源:PlayerController.php

示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Player();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Player'])) {
         $model->attributes = $_POST['Player'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', 'Player created');
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:cfletcher1856,项目名称:austinblinddraw,代码行数:18,代码来源:PlayerController.php

示例9: actionReg

 public function actionReg()
 {
     $email = trim(Yii::app()->request->getParam('email'));
     $nick = trim(Yii::app()->request->getParam('nickname'));
     $password = trim(Yii::app()->request->getParam('passwd'));
     $password2 = trim(Yii::app()->request->getParam('passwd2'));
     $refer = trim(Yii::app()->request->getParam('refer', '/'));
     if (!preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $email)) {
         $this->json_return(false, '请输入一个格式正确的Email地址');
     }
     if (!$password || $password != $password2) {
         $this->json_return(false, '2次输入的密码不一致');
     }
     if (!$nick) {
         $this->json_return(false, '请填写昵称');
     }
     if (mb_strlen($nick, 'UTF-8') > 9) {
         $this->json_return(false, '昵称长度请限制在9个字之内');
     }
     if (Player::model()->find('email=:email', array(':email' => $email))) {
         $this->json_return(false, '这个Email已经被注册了,您是否已经注册过了呢?');
     }
     if (Player::model()->find('nickname=:nick', array(':nick' => $nick))) {
         $this->json_return(false, '这个昵称已经被注册了,换一个吧');
     }
     $player = new Player();
     $player->email = $email;
     $player->nickname = $nick;
     $player->password = MyUserIdentity::hashpwd($password);
     $player->login_times = 0;
     $player->b_win = 0;
     $player->b_lose = 0;
     $player->w_win = 0;
     $player->w_lose = 0;
     $player->draw = 0;
     $player->reg_time = date('Y-m-d H:i:s');
     $player->reg_ip = MyController::getUserHostAddress();
     $player->last_login_time = date('Y-m-d H:i:s');
     $player->last_login_ip = MyController::getUserHostAddress();
     $player->score = Yii::app()->params['init_score'];
     if ($player->save()) {
         $identity = new MyUserIdentity($email, $password);
         if ($identity->authenticate()) {
             Yii::app()->user->login($identity, 3600);
             $this->json_return(true, '恭喜您注册成功!', $refer);
         }
     }
     $this->json_return(false, '注册失败啦,请与管理员联系。');
 }
开发者ID:xsir317,项目名称:5zer,代码行数:49,代码来源:MemberController.php

示例10: load

 public function load()
 {
     $this->clear();
     // Alfredo Rodriguez (Maryland)
     $player = new Player();
     $player->setFirstName('Alfredo');
     $player->setLastName('Rodriguez');
     $player->setHeight(72);
     $player->setWeight(180);
     $player->setBats('R');
     $player->setThrows('R');
     $player->setHometown('Oak Hill, Va.');
     $player->setCstvId(395839);
     $player->setNcaaId(993788);
     $player->save();
     print_r(sprintf("Created Player: %s (%s)\n", $player->getName(), $player->getId()));
 }
开发者ID:bigjoevtrj,项目名称:codeigniter-bootstrap,代码行数:17,代码来源:player.php

示例11: test_player_obj

function test_player_obj()
{
    // in: player_id, out: valid db save
    DatabaseConnection::getInstance();
    $player_id_sel = DatabaseConnection::$pdo->query("SELECT player_id FROM players WHERE uname = 'glassbox'");
    $player_id = $player_id_sel->fetchColumn();
    $player = new Player($player_id);
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player uname, out: valid db save
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player status check, out: no errors
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player, out: vo of player data
    $player = new Player('glassbox');
    $vo = $player->as_vo();
    assert($vo instanceof PlayerVO);
    // in: player, out: array of player data
    $player = new Player('glassbox');
    $arr = $player->as_array();
    assert(count($arr) > 0);
    var_dump($arr);
}
开发者ID:reillo,项目名称:ninjawars,代码行数:45,代码来源:lib_char_tests.php

示例12: test_player_obj

function test_player_obj()
{
    // in: player_id, out: valid db save
    $player_id_sel = "select player_id from players where uname = 'glassbox'";
    $db = new DBAccess();
    $player_id = $db->QueryItem($player_id_sel);
    $player = new Player($player_id);
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player uname, out: valid db save
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player status check, out: no errors
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player, out: vo of player data
    $player = new Player('glassbox');
    $vo = $player->as_vo();
    assert($vo instanceof PlayerVO);
    // in: player, out: array of player data
    $player = new Player('glassbox');
    $arr = $player->as_array();
    assert(count($arr) > 0);
    var_dump($arr);
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:45,代码来源:lib_char_tests.php

示例13: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Player();
     $document = new DocumentPlayer();
     $document->ID_DOCUMENT = 1;
     $document->ID_PLAYER = 1;
     $document->NAME = 'Acta de Juanito Perez';
     $document->PATH = 'En case la verga';
     $document->SIZE = 2;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Player'])) {
         $model->attributes = $_POST['Player'];
         //$document->save();
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->ID));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:elgodmaster,项目名称:soccer2,代码行数:24,代码来源:PlayerController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rand = 'GSP' . rand(100, 100000);
     $data = Input::all();
     $validator = Validator::make($data, Player::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     // Helper: File Upload in Player Model
     $check = Player::all()->count();
     if ($check >= 11) {
         return View::make('players.index')->with('message', 'You have reached the maximum number allowed');
     } else {
         $data['id_copy'] = Player::uploadFile(Input::file('id_copy'), 'id_copy');
         $data['photo'] = Player::uploadFile(Input::file('photo'), 'photo');
         $players = new Player($data);
         $players->rand_num = $rand;
         $players->save();
         return View::make('players.index')->with('message', 'file upload was successful');
     }
 }
开发者ID:Homeboyzandroid,项目名称:greensport,代码行数:26,代码来源:PlayersController.php

示例15: run

 protected function run()
 {
     if ($this->check == self::OK) {
         $colorRepository = new ColorRepository();
         $count = $colorRepository->getCountAll();
         $randomColor = mt_rand(1, $count);
         $userParams = array('username' => 'AI-' . str_pad(mt_rand(0, 999), 3, 0, STR_PAD_LEFT), 'color' => $randomColor);
         $userRepository = new UserRepository();
         $newUser = $userRepository->getOneByUsername($userParams['username']);
         if (!$newUser) {
             $newUser = new User($userParams);
             $newUser = $newUser->save(TRUE);
         }
         $playersCount = GameUtils::getPosition($this->game);
         $strategyRepository = new AiStrategyRepository();
         $strategyRepository->addOrderBy(array('RAND()' => ''));
         $strategy = $strategyRepository->getOneBy();
         $params = array('game' => $this->game['id'], 'user' => $newUser['id'], 'seat' => GameUtils::getSeatOnPosition($playersCount), 'ai_strategy' => $strategy['id']);
         $player = new Player($params);
         $player->save();
     }
 }
开发者ID:Tomeno,项目名称:lulcobang,代码行数:22,代码来源:AddAiPlayerCommand.php


注:本文中的Player::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。