本文整理汇总了PHP中Match::GetOvers方法的典型用法代码示例。如果您正苦于以下问题:PHP Match::GetOvers方法的具体用法?PHP Match::GetOvers怎么用?PHP Match::GetOvers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::GetOvers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveBowlingScorecard
/**
* @return array of IDs of players featured in records added, updated or deleted
* @param Match $match
* @param bool $is_home_innings
* @param int $batting_match_team_id
* @param int $bowling_match_team_id
* @param Overs[] $team_bowling
* @desc Saves the bowling scorecard for one innings
*/
private function SaveBowlingScorecard(Match $match, $is_home_innings, $batting_match_team_id, $bowling_match_team_id, $team_bowling)
{
require_once "stoolball/player-manager.class.php";
$player_manager = new PlayerManager($this->GetSettings(), $this->GetDataConnection());
# Get tables
$bowling_table = $this->GetSettings()->GetTable("Bowling");
$unchanged_overs = array();
$new_overs = array();
$bowling_deleted = false;
$affected_players = array();
# check if bowling updated for this innings
$position = 0;
foreach ($team_bowling as $bowling) {
$position++;
/* @var $bowling Over */
$sql = "SELECT bowling_id FROM {$bowling_table} WHERE\r\n\t\t\t\t\tmatch_team_id = {$bowling_match_team_id}\r\n\t\t\t\t\tAND player_id = " . Sql::ProtectNumeric($player_manager->SaveOrMatchPlayer($bowling->GetPlayer())) . "\r\n\t\t\t\t\tAND position = {$position}\r\n\t\t\t\t\tAND balls_bowled " . Sql::ProtectNumeric($bowling->GetBalls(), true, true) . "\r\n\t\t\t\t\tAND no_balls " . Sql::ProtectNumeric($bowling->GetNoBalls(), true, true) . "\r\n\t\t\t\t\tAND wides " . Sql::ProtectNumeric($bowling->GetWides(), true, true) . "\r\n\t\t\t\t\tAND runs_in_over " . Sql::ProtectNumeric($bowling->GetRunsInOver(), true, true);
$result = $this->GetDataConnection()->query($sql);
if ($row = $result->fetch()) {
$unchanged_overs[] = $row->bowling_id;
} else {
# Save id of bowler added or updated
$bowler_id = $player_manager->SaveOrMatchPlayer($bowling->GetPlayer());
$affected_players[] = $bowler_id;
$sql = "INSERT INTO {$bowling_table} SET\r\n\t\t\t\t\tmatch_team_id = {$bowling_match_team_id},\r\n\t\t\t\t\tplayer_id = " . Sql::ProtectNumeric($bowler_id) . ",\r\n\t\t\t\t\tposition = {$position},\r\n\t\t\t\t\tballs_bowled = " . Sql::ProtectNumeric($bowling->GetBalls(), true) . ",\r\n\t\t\t\t\tno_balls = " . Sql::ProtectNumeric($bowling->GetNoBalls(), true) . ",\r\n\t\t\t\t\twides = " . Sql::ProtectNumeric($bowling->GetWides(), true) . ",\r\n\t\t\t\t\truns_in_over = " . Sql::ProtectNumeric($bowling->GetRunsInOver(), true) . ",\r\n\t\t\t\t\tdate_added = " . gmdate('U');
$new_overs[] = $sql;
}
}
# see if there are existing bowling records for this innings which we need to delete
$sql = "SELECT bowling_id, player_id FROM {$bowling_table} WHERE match_team_id = {$bowling_match_team_id}";
# match_team_id is autonumber from db so can be trusted
if (count($unchanged_overs)) {
$sql .= " AND bowling_id NOT IN (" . implode(",", $unchanged_overs) . ")";
}
$result = $this->GetDataConnection()->query($sql);
# Save ID of bowler updated or deleted
while ($row = $result->fetch()) {
$affected_players[] = $row->player_id;
$bowling_deleted = true;
}
# If anything has changed...
if ($bowling_deleted or count($new_overs)) {
# All changes to master data are logged, because this method can be called from the public interface
# Delete existing bowling for this innings
if ($bowling_deleted) {
$sql = "DELETE FROM {$bowling_table} WHERE match_team_id = {$bowling_match_team_id}";
# match_team_id is autonumber from db so can be trusted
if (count($unchanged_overs)) {
$sql .= " AND bowling_id NOT IN (" . implode(",", $unchanged_overs) . ")";
}
$this->LoggedQuery($sql);
}
# Insert bowling for this innings if changed or added
foreach ($new_overs as $sql) {
$this->LoggedQuery($sql);
}
# Match data has changed so record for audit, and notify moderator.
# We can also update the number of overs so that the same number of boxes are shown next time.
$overs_bowled = $match->GetOvers();
$sql = "UPDATE nsa_match SET\r\n\t\t\t overs = {$overs_bowled}, \r\n date_changed = " . gmdate('U') . ", \r\n modified_by_id = " . Sql::ProtectNumeric(AuthenticationManager::GetUser()->GetId()) . ' ' . "WHERE match_id " . Sql::ProtectNumeric($match->GetId(), false, true);
$this->LoggedQuery($sql);
$this->QueueForNotification($match->GetId(), false);
}
return $affected_players;
}
示例2: CreateFixtureControls
//.........这里部分代码省略.........
$player_radios->AddControl($player_radios_2);
$player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Ladies', $this->GetNamingPrefix() . 'PlayerType', 'Ladies', 2, $suggested_type === 2, $this->IsValidSubmit()));
$player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Mixed', $this->GetNamingPrefix() . 'PlayerType', 'Mixed', 1, $suggested_type === 1, $this->IsValidSubmit()));
$player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Girls', $this->GetNamingPrefix() . 'PlayerType', 'Junior girls', 5, $suggested_type === 5, $this->IsValidSubmit()));
$player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Children', $this->GetNamingPrefix() . 'PlayerType', 'Junior mixed', 4, $suggested_type === 6, $this->IsValidSubmit()));
$match_box->AddControl($player_set);
# How many?
$per_side_box = new XhtmlSelect($this->GetNamingPrefix() . "Players", null, $this->IsValid());
$per_side_box->SetBlankFirst(true);
for ($i = 6; $i <= 16; $i++) {
$per_side_box->AddControl(new XhtmlOption($i));
}
if ($match->GetIsMaximumPlayersPerTeamKnown()) {
$per_side_box->SelectOption($match->GetMaximumPlayersPerTeam());
} else {
if (!$match->GetId()) {
# Use eight as sensible default for new tournaments
$per_side_box->SelectOption(8);
}
}
$players_per_team = new XhtmlElement("label", $per_side_box);
$players_per_team->AddAttribute("for", $this->GetNamingPrefix() . "Players");
$players_per_team->AddControl(" players per team");
$players_part = new FormPart("How many players?", $players_per_team);
$players_part->AddCssClass("playersPerTeam");
$match_box->AddControl($players_part);
# Overs
$overs_box = new XhtmlSelect($this->GetNamingPrefix() . "Overs", null, $this->IsValid());
$overs_box->SetBlankFirst(true);
for ($i = 2; $i <= 8; $i++) {
$overs_box->AddControl(new XhtmlOption($i));
}
if ($match->GetIsOversKnown()) {
$overs_box->SelectOption($match->GetOvers());
}
$overs_label = new XhtmlElement("label", "Overs per innings");
$overs_label->AddAttribute("for", $overs_box->GetXhtmlId());
$overs_part = new FormPart($overs_label, new XhtmlElement("div", $overs_box));
$overs_part->AddCssClass("overs");
$match_box->AddControl($overs_part);
# Start date and time
if (!$match->GetStartTime()) {
# if no date set, use specified default
if ($this->i_default_time) {
$match->SetStartTime($this->i_default_time);
} else {
# if no date set and no default, default to today at 10.30am BST
# NOTE that if this is a new tournament in an old season, this date won't be selected because the available
# dates will be limited below and won't include today. It'll be the same day in the relevant year though.
$i_now = gmdate('U');
$match->SetStartTime(gmmktime(9, 30, 00, (int) gmdate('n', $i_now), (int) gmdate('d', $i_now), (int) gmdate('Y', $i_now)));
$match->SetIsStartTimeKnown(true);
}
}
$o_date = new DateControl($this->GetNamingPrefix() . 'Start', $match->GetStartTime(), $match->GetIsStartTimeKnown(), $this->IsValidSubmit());
$o_date->SetShowTime(true);
$o_date->SetRequireTime(false);
$o_date->SetMinuteInterval(5);
# if only one season to choose from, limit available dates to the length of that season
if ($this->context_season instanceof Season) {
if ($this->context_season->GetStartYear() == $this->context_season->GetEndYear()) {
$i_mid_season = gmmktime(0, 0, 0, 6, 30, $this->context_season->GetStartYear());
} else {
$i_mid_season = gmmktime(0, 0, 0, 12, 31, $this->context_season->GetStartYear());
}
$season_dates = Season::SeasonDates($i_mid_season);
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:67,代码来源:tournament-edit-control.class.php
示例3: BuildPostedScorecard
//.........这里部分代码省略.........
$player->Team()->SetId($home_batting ? $home_team->GetId() : $away_team->GetId());
$batting = new Batting($player, null, null, null, (int) $_POST[$key]);
if ($home_batting) {
$match->Result()->HomeBatting()->Add($batting);
} else {
$match->Result()->AwayBatting()->Add($batting);
}
}
$key = "batWides";
if (isset($_POST[$key]) and is_numeric($_POST[$key])) {
$player = new Player($this->GetSettings());
$player->SetPlayerRole(Player::WIDES);
$player->Team()->SetId($home_batting ? $home_team->GetId() : $away_team->GetId());
$batting = new Batting($player, null, null, null, (int) $_POST[$key]);
if ($home_batting) {
$match->Result()->HomeBatting()->Add($batting);
} else {
$match->Result()->AwayBatting()->Add($batting);
}
}
$key = "batNoBalls";
if (isset($_POST[$key]) and is_numeric($_POST[$key])) {
$player = new Player($this->GetSettings());
$player->SetPlayerRole(Player::NO_BALLS);
$player->Team()->SetId($home_batting ? $home_team->GetId() : $away_team->GetId());
$batting = new Batting($player, null, null, null, (int) $_POST[$key]);
if ($home_batting) {
$match->Result()->HomeBatting()->Add($batting);
} else {
$match->Result()->AwayBatting()->Add($batting);
}
}
$key = "batBonus";
if (isset($_POST[$key]) and is_numeric($_POST[$key])) {
$player = new Player($this->GetSettings());
$player->SetPlayerRole(Player::BONUS_RUNS);
$player->Team()->SetId($home_batting ? $home_team->GetId() : $away_team->GetId());
$batting = new Batting($player, null, null, null, (int) $_POST[$key]);
if ($home_batting) {
$match->Result()->HomeBatting()->Add($batting);
} else {
$match->Result()->AwayBatting()->Add($batting);
}
}
$key = "batTotal";
if (isset($_POST[$key]) and is_numeric($_POST[$key])) {
if ($home_batting) {
$match->Result()->SetHomeRuns($_POST[$key]);
} else {
$match->Result()->SetAwayRuns($_POST[$key]);
}
}
$key = "batWickets";
if (isset($_POST[$key]) and is_numeric($_POST[$key])) {
if ($home_batting) {
$match->Result()->SetHomeWickets($_POST[$key]);
} else {
$match->Result()->SetAwayWickets($_POST[$key]);
}
}
# Read posted bowling data
$key = "bowlerRows";
if (isset($_POST[$key])) {
# This controls not only which fields are read, but also which are redisplayed on an invalid postback or for the next innings.
$match->SetOvers(intval($_POST[$key]));
}
for ($i = 1; $i <= $match->GetOvers(); $i++) {
$key = "bowlerName{$i}";
if (isset($_POST[$key])) {
# The row exists - has it been filled in?
if (trim($_POST[$key])) {
# Read the bowler data in this row
# strlen test allows 0 but not empty string, because is_numeric allows empty string
$player = new Player($this->GetSettings());
$player->SetName($_POST[$key]);
$player->Team()->SetId($home_batting ? $away_team->GetId() : $home_team->GetId());
$key = "bowlerBalls{$i}";
$balls = (isset($_POST[$key]) and is_numeric($_POST[$key]) and strlen(trim($_POST[$key]))) ? (int) $_POST[$key] : null;
$key = "bowlerNoBalls{$i}";
$no_balls = (isset($_POST[$key]) and is_numeric($_POST[$key]) and strlen(trim($_POST[$key]))) ? (int) $_POST[$key] : null;
$key = "bowlerWides{$i}";
$wides = (isset($_POST[$key]) and is_numeric($_POST[$key]) and strlen(trim($_POST[$key]))) ? (int) $_POST[$key] : null;
$key = "bowlerRuns{$i}";
$runs = (isset($_POST[$key]) and is_numeric($_POST[$key]) and strlen(trim($_POST[$key]))) ? (int) $_POST[$key] : null;
# Add that over to the match result
$bowling = new Over($player);
$bowling->SetBalls($balls);
$bowling->SetNoBalls($no_balls);
$bowling->SetWides($wides);
$bowling->SetRunsInOver($runs);
if ($home_batting) {
$match->Result()->AwayOvers()->Add($bowling);
} else {
$match->Result()->HomeOvers()->Add($bowling);
}
}
}
}
return $match;
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:101,代码来源:scorecard-edit-control.class.php