當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Game::commit方法代碼示例

本文整理匯總了PHP中Game::commit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Game::commit方法的具體用法?PHP Game::commit怎麽用?PHP Game::commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Game的用法示例。


在下文中一共展示了Game::commit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: shouldBeAbleToSetAndGetFenOnGame

 /**
  * @test
  */
 public function shouldBeAbleToSetAndGetFenOnGame()
 {
     // given
     $game = new Game();
     $fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
     $expectedFen = $this->getExpectedStorageFen($fen);
     // when
     $game->setFen($fen);
     $game->commit();
     $this->assertEquals(1, $game->getFenId(), "Fen id is numeric before");
     $this->assertEquals($expectedFen, $game->getFen(), "Fen before");
     $newGame = new Game($game->getId());
     // then
     $this->assertEquals(1, $newGame->getFenId(), "Fen id is numeric after");
     $this->assertEquals($expectedFen, $newGame->getFen());
 }
開發者ID:manishkhanchandani,項目名稱:mkgxy,代碼行數:19,代碼來源:GameTest.php

示例2: array

 * User: Alf Magne
 * Date: 23.01.13
 * Time: 14:52
 * To change this template use File | Settings | File Templates.
 */
ini_set('display_errors', 'on');
date_default_timezone_set("Europe/Berlin");
require_once __DIR__ . "/../autoload.php";
LudoDB::setHost('127.0.0.1');
LudoDB::setUser('root');
LudoDB::setPassword('administrator');
LudoDB::setDb('PHPUnit');
// Construct database tables
$tables = array('Move', 'Game', 'Fen', 'Metadata', 'MetadataValue');
foreach ($tables as $table) {
    $inst = new $table();
    $inst->drop()->yesImSure();
    $inst->createTable();
}
$profiling = new XHPProfiling('PGN to parser to DB');
$parser = new PgnParser("../../pgn/profiling.pgn");
$games = $parser->getGames();
foreach ($games as $gameData) {
    $game = new Game();
    $game->setDatabaseId(100);
    $game->setFen($gameData['metadata']['fen']);
    $game->setMetadata($gameData['metadata']);
    $game->setMoves($gameData['moves']);
    $game->commit();
}
echo $profiling->end();
開發者ID:manishkhanchandani,項目名稱:mkgxy,代碼行數:31,代碼來源:import-profiling.php

示例3: createGameMetadata

 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();
 }
開發者ID:manishkhanchandani,項目名稱:mkgxy,代碼行數:15,代碼來源:MetadataTest.php


注:本文中的Game::commit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。