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; }
public function addGameRow(Game $oGame, $includeField = true) { $oGame = Game::getByNefubId($oGame->nefub_id); $field = $oGame->field ? $oGame->field : 1; $gameType = $oGame->getCompetition()->getGender()->name . ' ' . $oGame->getCompetition()->getGenre()->name; $team1 = utf8_decode($oGame->getTeam1()->name); $team2 = utf8_decode($oGame->getTeam2()->name); if ($oGame->getFirstReferee()) { $oGame = new Game($oGame->getId()); $oReferee = $oGame->getFirstReferee(); $referee = utf8_decode($oReferee->getName()); if (!$oReferee->getPerson()) { $referee .= ' (' . $oReferee->getTeam()->getCompetition()->getGender()->name; $referee .= ' ' . $oReferee->getTeam()->getCompetition()->getGenre()->name . ')'; } } else { $referee = 'Onbekend'; } $text = $oGame->getFormattedTime(); $text .= "\t"; $text .= $team1; $text .= "\t"; $text .= $team2; $text .= "\n"; $text .= $gameType; if ($includeField) { $text .= $field; } $this->section->addText($text, array('name' => 'Arial', 'size' => 10, 'bold' => false)); }
/** * Declares an association between this object and a Game object. * * @param Game $v * @return User The current object (for fluent API support) * @throws PropelException */ public function setGame(Game $v = null) { if ($v === null) { $this->setCurrentGameId(NULL); } else { $this->setCurrentGameId($v->getId()); } $this->aGame = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Game object, it will not be re-added. if ($v !== null) { $v->addUser($this); } return $this; }
private function createGameMetadata($gameId, $key, $value) { // given $game = new Game($gameId); if (!$game->getId()) { $game->setValues(array("id", $gameId, "white" => "Alf")); $game->commit(); } $m = new MetadataValue($key); // when $m->setGameid($gameId); $m->setMetadataKey($key); $m->setMetadataValue($value); $m->commit(); }
private function importGame($game, $intoDb = null) { $game['database_id'] = $intoDb; $g = new Game(); $g->save($game); return $g->getId(); }
<?php require_once './class/Game.class.php'; session_start(); if (count($_SESSION) == 0) { $game = new Game(); $_SESSION['party_id'] = $game->getId(); $game->save(); } else { header('Location: game.php'); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Game $value A Game object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Game $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
private function getGameWithAMove() { $game = new Game(); $game->appendMove('e4'); return $game->getId(); }