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


PHP Game::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $game = new Game();
     $game->fill(Input::all());
     $game->save();
     return Redirect::action('GameController@index');
 }
开发者ID:sammy8806,项目名称:gsi_laravel,代码行数:12,代码来源:GameController.php

示例2: executeCreate

 public function executeCreate(sfWebRequest $request)
 {
     $user = UserPeer::retrieveByPk($request->getParameter('username'));
     if (!$user) {
         $arr = array();
         $arr["result"] = false;
         $arr["message"] = "Invalid username";
         $this->renderText(json_encode($arr));
         return sfView::NONE;
     }
     $game = new Game();
     $game->setIsPublic($request->getParameter('public', 0));
     $game->setStartTime(time());
     $game->setIsActive(true);
     $game->setLatitude($request->getParameter('latitude'));
     $game->setLongitude($request->getParameter('longitude'));
     $game->save();
     $gameMember = new GameMember();
     $gameMember->setUserId($user->getId());
     $gameMember->setGameId($game->getId());
     $gameMember->setIsActive(true);
     $gameMember->save();
     $user->setCurrentGameId($game->getId());
     $this->updateUserLocation($user, $request);
     $arr = array();
     $arr["result"] = true;
     $arr["message"] = "Game created, game number is " . $game->getId() . ".  When others join, you will be assigned a target";
     $this->renderText(json_encode($arr));
     return sfView::NONE;
 }
开发者ID:adatta02,项目名称:comp194ma,代码行数:30,代码来源:actions.class.php

示例3: endGame

 protected function endGame($roles)
 {
     $playerRepository = new PlayerRepository();
     $players = $playerRepository->getByGameAndRole($this->game['id'], $roles);
     $playersNames = array();
     foreach ($players as $player) {
         $player['winner'] = 1;
         $player->save();
         $user = $player->getUser();
         $playersNames[] = $user['username'];
     }
     // znovu nacitame actual a attacking playera lebo to robi nejake halusky
     if ($this->actualPlayer) {
         $this->actualPlayer = $playerRepository->getOneById($this->actualPlayer['id']);
     }
     if ($this->attackingPlayer) {
         $this->attackingPlayer = $playerRepository->getOneById($this->attackingPlayer['id']);
     }
     // vytvorit nejaku tabulku hall of fame kde budu vyhry a prehry
     // vyhry a prehry za nejaku konkretnu rolu  - typ roly - cize je jedno ci si bandita1 alebo bandita2
     $message = array('text' => 'vyhrali hraci: ' . implode(', ', $playersNames), 'user' => User::SYSTEM);
     $this->addMessage($message);
     $this->game['status'] = Game::GAME_STATUS_ENDED;
     $this->game->save();
 }
开发者ID:Tomeno,项目名称:lulcobang,代码行数:25,代码来源:Command.php

示例4: handleCreate

 public function handleCreate()
 {
     $game = new Game();
     $game->title = Input::get('title');
     $game->publisher = Input::get('publisher');
     $game->completed = Input::has('completed');
     $game->save();
     return Redirect::action('GamesController@index');
 }
开发者ID:jay3ss,项目名称:cb_games,代码行数:9,代码来源:GamesController.php

示例5: beforeSave

 public function beforeSave()
 {
     if (preg_match('/^ん$/u', mb_substr($this->data['Word']['pronunciation'], -1, 1, 'UTF-8')) === 1) {
         App::import('Model', 'Game');
         $game = new Game();
         $game->save(array('id' => $this->data['Word']['game_id'], 'is_active' => false), false, array('is_active'));
     }
     return parent::beforeSave();
 }
开发者ID:ndyuya,项目名称:word-chain-game,代码行数:9,代码来源:Word.php

示例6: addGame

 public function addGame($args)
 {
     $model = new Game();
     $model->setAttributes($args);
     if ($model->save(FALSE)) {
         return $model->id;
     }
     return FALSE;
 }
开发者ID:huynt57,项目名称:quizder,代码行数:9,代码来源:Game.php

示例7: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aGame !== null) {
             if ($this->aGame->isModified() || $this->aGame->isNew()) {
                 $affectedRows += $this->aGame->save($con);
             }
             $this->setGame($this->aGame);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = UserPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += UserPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collTargetsRelatedByFromUserId !== null) {
             foreach ($this->collTargetsRelatedByFromUserId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collTargetsRelatedByToUserId !== null) {
             foreach ($this->collTargetsRelatedByToUserId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collGameMembers !== null) {
             foreach ($this->collGameMembers as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:adatta02,项目名称:comp194ma,代码行数:67,代码来源:BaseUser.php

示例8: createMultiple

 public function createMultiple($round)
 {
     foreach (Input::get('games') as $game) {
         $g = new Game();
         $g->round = $round->id;
         $g->slug = $game['slug'];
         $g->map = $game['map'];
         $g->save();
         App::make('ReportsController')->createMultiple($g, $game['players']);
     }
 }
开发者ID:romainmasc,项目名称:jackmarshall,代码行数:11,代码来源:GamesController.php

示例9: handleCreate

 public function handleCreate()
 {
     if (Auth::guest()) {
         return Redirect::action('UserController@login');
     }
     // Handle create form submission.
     $game = new Game();
     $game->title = Input::get('title');
     $game->publisher = Input::get('publisher');
     $game->complete = Input::has('complete');
     $game->user_id = Auth::user()->id;
     $game->save();
     return Redirect::action('GamesController@index');
 }
开发者ID:georgi-yankov,项目名称:gsy-laravel,代码行数:14,代码来源:GamesController.php

示例10: run

 public function run()
 {
     $i = 0;
     foreach (array_keys(Config::get('devices')) as $device) {
         foreach (array_keys(Config::get('genres')) as $genre) {
             $game = new Game();
             $game->game_title = "game {$i}";
             $game->device = $device;
             $game->genre = $genre;
             $game->save();
             $i++;
         }
     }
 }
开发者ID:BobFromAccounting,项目名称:events.dev,代码行数:14,代码来源:GamesTableSeeder.php

示例11: store

 public static function store()
 {
     $params = $_POST;
     $rain = isset($_POST['rain']) && $_POST['rain'] ? "1" : "0";
     // checked=1, unchecked=0
     $wet_no_rain = isset($_POST['wet_no_rain']) && $_POST['wet_no_rain'] ? "1" : "0";
     // checked=1, unchecked=0
     $windy = isset($_POST['windy']) && $_POST['windy'] ? "1" : "0";
     // checked=1, unchecked=0
     $variant = isset($_POST['variant']) && $_POST['variant'] ? "1" : "0";
     // checked=1, unchecked=0
     $dark = isset($_POST['dark']) && $_POST['dark'] ? "1" : "0";
     // checked=1, unchecked=0
     $led = isset($_POST['led']) && $_POST['led'] ? "1" : "0";
     // checked=1, unchecked=0
     $snow = isset($_POST['snow']) && $_POST['snow'] ? "1" : "0";
     // checked=1, unchecked=0
     $date = $_POST['date'];
     $time = $_POST['time'];
     $comment = $_POST['comment'];
     $courseid = $_POST['courseid'];
     $gamedate = $date . " " . $time . ":00";
     $game = new Game(array('courseid' => $courseid, 'gamedate' => $gamedate, 'comment' => $comment, 'rain' => $rain, 'wet_no_rain' => $wet_no_rain, 'windy' => $windy, 'variant' => $variant, 'dark' => $dark, 'led' => $led, 'snow' => $snow));
     $errors = $game->errors();
     $course = Course::find($courseid);
     $scores = array();
     // When implementing multiple players per game, cycle through playerid's here
     $playerid = $_POST['playerid'];
     foreach ($course->holes as $hole) {
         $stroke = $_POST['hole' . $hole->hole_num];
         // 'holeN' will be something like 'playername-holeN'
         $ob = $_POST['obhole' . $hole->hole_num];
         $score = new Score(array('holeid' => $hole->holeid, 'playerid' => $playerid, 'stroke' => $stroke, 'ob' => $ob));
         $errors = array_merge($errors, $score->errors());
         $scores[] = $score;
     }
     if (count($errors) == 0) {
         // Game and scores were all valid
         $gameid = $game->save();
         foreach ($scores as $score) {
             $score->gameid = $gameid;
             $score->save();
         }
         Redirect::to('/game/' . $game->gameid, array('message' => 'Peli ja sen tulokset lisätty.'));
     } else {
         View::make('game/new.html', array('errors' => $errors, 'attributes' => $params, 'course' => $course));
     }
 }
开发者ID:rryanburton,项目名称:Tsoha-Bootstrap,代码行数:48,代码来源:game_controller.php

示例12: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->aGame !== null) {
             if ($this->aGame->isModified() || $this->aGame->isNew()) {
                 $affectedRows += $this->aGame->save($con);
             }
             $this->setGame($this->aGame);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = GameMemberPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = GameMemberPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += GameMemberPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:adatta02,项目名称:comp194ma,代码行数:57,代码来源:BaseGameMember.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Fetch all request data.
     $data = Input::only('title', 'game_icon');
     // Build the validation constraint set.
     $rules = array('title' => array('required'));
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $game = new Game();
         $title = Input::get('title');
         //$uniqid = str_shuffle(uniqid());
         $game->slug = Str::slug($title, '-');
         $game->title = $title;
         $game->game_icon = Input::get('game_icon');
         $game->save();
         Cache::forget('games');
         return Redirect::to('/')->with('global_success', 'Game submitted successfully!');
     }
     return Redirect::to('/game/add')->withInput()->withErrors($validator)->with('message', 'Validation Errors!');
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:26,代码来源:GameController.php

示例14: switch

include_once "classes/Game.php";
include_once "classes/GameTable.php";
include_once "classes/ActionType.php";
if (isset($_POST['action'])) {
    $action = $_POST['action'];
    $return = true;
    switch ($action) {
        case ActionType::ACTION_SAVE:
            $name = $_POST['name'];
            $gameType = $_POST['gameType'];
            $year = $_POST['year'];
            $rating = $_POST['rating'];
            $company = $_POST['company'];
            try {
                $game = new Game(null, $gameType, $name, $rating, $year, $company);
                $game->save();
            } catch (PDOException $exception) {
                $return = false;
            }
            break;
        case ActionType::ACTION_DELETE:
            $id = $_POST['id'];
            try {
                $game = new Game($id, null, null, null, null, null);
                $game->delete();
            } catch (PDOException $exception) {
                $return = false;
            }
            break;
        case ActionType::ACTION_MODIFY:
            $name = $_POST['name'];
开发者ID:nahual,项目名称:qc-elPibePlay,代码行数:31,代码来源:GameAjaxController.php

示例15: saveGames

 public function saveGames($games)
 {
     $documents = array();
     $new = array();
     print_r("Saving " . count($games) . " Game Listings\n");
     foreach ($games as $game) {
         $homeSlug = $this->slugify->simple($game['homeTeam']);
         $homeTeam = $this->_team->findOneBySlug($homeSlug);
         if (!$homeTeam) {
             $homeTeam = $this->_team->createByName($game['homeTeam']);
         }
         $homeTeam = $this->mongo->create_dbref('team', $homeTeam->getId());
         $awaySlug = $this->slugify->simple($game['awayTeam']);
         $awayTeam = $this->_team->findOneBySlug($awaySlug);
         if (!$awayTeam) {
             $awayTeam = $this->_team->createByName($game['awayTeam']);
         }
         $awayTeam = $this->mongo->create_dbref('team', $awayTeam->getId());
         //print_r($homeTeam);
         //print_r($awayTeam);
         $datetime = new MongoDate(strtotime($game['date']));
         $document = $this->findOneByDateWithTeamsAndScores($datetime, $homeTeam, $awayTeam, $game['homeScore'], $game['awayScore']);
         if (!$document) {
             $document = new Game();
             $document->setDatetime($datetime);
             $document->setHomeTeam($homeTeam);
             $document->setAwayTeam($awayTeam);
             $document->setHomeScore($game['homeScore']);
             $document->setAwayScore($game['awayScore']);
             $document->setUrl($game['url']);
             $document->save();
             array_push($new, $document);
         }
         if (!in_array($document, $documents)) {
             array_push($documents, $document);
         }
         print_r('.');
         //print_r(count($documents));
     }
     if (count($games)) {
         print_r("\n");
     }
     print_r("Added " . count($new) . " New Games\n");
     return $documents;
 }
开发者ID:bigjoevtrj,项目名称:codeigniter-bootstrap,代码行数:45,代码来源:inningrepository.php


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