Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ViewFromTheBox/5e8fe4d4607d494a2c55e6b1806c5ca5 to your computer and use it in GitHub Desktop.

Select an option

Save ViewFromTheBox/5e8fe4d4607d494a2c55e6b1806c5ca5 to your computer and use it in GitHub Desktop.
For more information, go to: https://sportsbenchwp.com
public function get_goals( $season = false ) {
if ( $season == false ) {
$where = '';
} else {
$where = ' AND game_season = "' . $season . '" ';
}
global $wpdb;
$player_table = $wpdb->prefix . 'sb_players';
$game_stats_table = $wpdb->prefix . 'sb_game_stats';
$game_table = $wpdb->prefix . 'sb_games';
$player_id = $this->player_id;
$querystr = "SELECT p.player_id, p.player_first_name, p.player_last_name, p.team_id, game.game_id, game.game_season, g.game_id, g.game_team_id, g.game_player_id, SUM( g.game_player_goals ) as GOALS
FROM $player_table as p LEFT JOIN $game_stats_table as g
ON p.player_id = g.game_player_id
LEFT JOIN $game_table as game
ON game.game_id = g.game_id
WHERE g.game_player_id = $player_id AND game.game_status = 'final' $where
GROUP BY g.game_player_id, game.game_season;";
$goals = $wpdb->get_results( $querystr );
return $goals[0]->GOALS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment