本文整理汇总了PHP中Game::errors方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::errors方法的具体用法?PHP Game::errors怎么用?PHP Game::errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::errors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public static function update($id)
{
$params = $_POST;
$attributes = array('id' => $id, 'name' => $params['name'], 'played' => $params['played'], 'published' => $params['published'], 'description' => $params['description']);
// Alustetaan Game-olio käyttäjän syöttämillä tiedoilla
$game = new Game($attributes);
$errors = $game->errors();
if (count($errors) > 0) {
View::make('game/edit.html', array('errors' => $errors, 'attributes' => $attributes));
} else {
// Kutsutaan alustetun olion update-metodia, joka päivittää pelin tiedot tietokannassa
$game->update();
//Redirect::to('/game/' . $game->id, array('message' => 'Peliä on muokattu onnistuneesti!'));
}
}
示例2: update
public static function update($gameid)
{
$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('gameid' => $gameid, '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);
// When implementing multiple players per game, cycle through playerid's here
$playerid = $_POST['playerid'];
$player_scores = Score::all_game_scores($gameid);
foreach ($player_scores as $playername => $scores) {
foreach ($scores as $score) {
$stroke = $_POST['hole' . $score->hole->hole_num];
// 'holeN' will be something like 'playername-holeN'
$ob = $_POST['obhole' . $score->hole->hole_num];
$score->stroke = $stroke;
$score->ob = $ob;
$errors = array_merge($errors, $score->errors());
}
}
if (count($errors) == 0) {
// Game and scores were all valid
$gameid = $game->update();
foreach ($player_scores as $playername => $scores) {
foreach ($scores as $score) {
$score->update();
}
}
Redirect::to('/game/' . $game->gameid, array('message' => 'Peli ja sen tulokset päivitetty.'));
} else {
View::make('game/edit.html', array('errors' => $errors, 'game' => $game, 'date' => $date, 'time' => $time));
}
}
示例3: update
public static function update($gameid)
{
$attributes = $_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
$doubles = isset($_POST['doubles']) && $_POST['doubles'] ? "1" : "0";
// checked=1, unchecked=0
$temp = $_POST['temp'] != "" ? $_POST['temp'] : null;
// temperature can be null (or 0!)
$date = $_POST['date'];
$time = $_POST['time'];
$comment = $_POST['comment'];
$courseid = $_POST['courseid'];
$gamedate = $date . " " . $time . ":00";
$game = new Game(array('gameid' => $gameid, 'courseid' => $courseid, 'gamedate' => $gamedate, 'comment' => $comment, 'rain' => $rain, 'wet_no_rain' => $wet_no_rain, 'windy' => $windy, 'variant' => $variant, 'dark' => $dark, 'led' => $led, 'snow' => $snow, 'doubles' => $doubles, 'temp' => $temp));
$errors = $game->errors();
$course = Course::find($courseid);
$player_scores = Score::all_game_scores($gameid);
// Cycle through players
foreach ($player_scores as $playerid => $scores) {
// playerid is i.e. 'player4'
$legal_index = 'legal-' . $playerid;
$legal = isset($_POST[$legal_index]) && $_POST[$legal_index] ? "1" : "0";
// checked=1, unchecked=0
foreach ($scores as $score) {
// inputs are in format 'player1-hole1'
$stroke = $_POST[$playerid . '-hole' . $score->hole_num];
$ob = $_POST[$playerid . '-obhole' . $score->hole_num];
$score->stroke = (int) $stroke;
$score->ob = (int) $ob;
$score->legal = $legal;
$errors = array_merge($errors, $score->errors());
}
}
if (count($errors) == 0) {
// Game and scores were all valid
$gameid = $game->update();
foreach ($player_scores as $playerid => $scores) {
foreach ($scores as $score) {
$score->update();
}
}
// Clear cached pages
Cache::clear();
Redirect::to('/game/' . $game->gameid, array('message' => 'Peli ja sen tulokset päivitetty.'));
} else {
$game->prepare();
View::make('game/edit.html', array('errors' => $errors, 'game' => $game, 'date' => $date, 'time' => $time, 'players' => Game::games_players($gameid), 'attributes' => $attributes, 'course' => $game->course));
}
}