</tr>
    </thead>
    <?php 
$total = array("kill" => 0, "death" => 0, "hs" => 0, "bombe" => 0, "defuse" => 0, "tk" => 0, "point" => 0, "firstkill" => 0, "1v1" => 0, "1v2" => 0, "1v3" => 0, "1v4" => 0, "1v5" => 0, "1kill" => 0, "2kill" => 0, "3kill" => 0, "4kill" => 0, "5kill" => 0, "clutch" => 0, "assist" => 0);
?>
    <tbody>
        <?php 
foreach ($players as $player) {
    ?>
            <?php 
    if ($player->getTeam() != "b") {
        continue;
    }
    ?>
            <?php 
    $result = PlayerKillTable::getInstance()->createQuery()->select("COUNT(*) as nb, weapon")->where("match_id = ?", $match->getId())->andWhere("killer_id = ?", $player->getId())->orderBy("nb DESC")->groupBy("weapon")->fetchOne();
    if ($result) {
        $bestWeapon = $result->toArray();
    }
    $total['kill'] += $player->getNbKill();
    $total['assist'] += $player->getAssist();
    $total['death'] += $player->getDeath();
    $total['hs'] += $player->getHs();
    $total['bombe'] += $player->getBombe();
    $total['defuse'] += $player->getDefuse();
    $total['tk'] += $player->getTk();
    $total['point'] += $player->getPoint();
    $total['firstkill'] += $player->getFirstkill();
    $total['1v1'] += $player->getNb1();
    $total['1v2'] += $player->getNb2();
    $total['1v3'] += $player->getNb3();
});
</script>

<style>
    .highlight {
        font-weight: bolder;
    }

    .highlight_name {
        cursor: default;
    }
</style>

<?php 
$players = array();
$kills = PlayerKillTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->execute();
foreach ($kills as $kill) {
    @$players[$kill->getKillerId()][$kill->getKilledId()]++;
}
?>

<table class="table table-striped table-bordered" style="width: auto;" id="tableKilledKiller">
    <thead>
        <tr>
            <td></td>
            <?php 
$count = 0;
?>
            <?php 
foreach ($match->getMap()->getPlayer() as $player) {
    ?>
 public function executeExportEstats(sfWebRequest $request)
 {
     $mO = $this->getRoute()->getObject();
     $stats = array();
     $match = $mO->toArray();
     unset($match['id'], $match['config_password'], $match['season_id'], $match['server_id'], $match['rules'], $match['team_a'], $match['team_b'], $match['config_authkey'], $match['current_map']);
     $stats['match'] = $match;
     foreach ($mO->getMaps() as $mapO) {
         $map = $mapO->toArray();
         unset($map['match_id'], $map['id']);
         $stats['map'] = $map;
         foreach ($mapO->getMapsScore() as $sO) {
             $score = $sO->toArray();
             unset($score['id'], $score['map_id']);
             $stats['scores'][] = $score;
         }
     }
     foreach ($mO->getPlayers() as $pO) {
         $player = $pO->toArray();
         unset($player['map_id'], $player['match_id'], $player['ip']);
         $stats['players'][] = $player;
     }
     $heatmap = PlayersHeatmapTable::getInstance()->createQuery()->where("match_id = ?", $mO->getId())->orderBy("created_at ASC")->execute();
     foreach ($heatmap as $hO) {
         $data = $hO->toArray();
         unset($data['id'], $data['match_id'], $data['map_id']);
         $stats['heatmap'][] = $data;
     }
     $kills = PlayerKillTable::getInstance()->createQuery()->where("match_id = ?", $mO->getId())->orderBy("created_at ASC")->execute();
     foreach ($kills as $hO) {
         $data = $hO->toArray();
         unset($data['match_id'], $data['map_id']);
         $stats['kills'][] = $data;
     }
     $kills = RoundTable::getInstance()->createQuery()->where("match_id = ?", $mO->getId())->orderBy("created_at ASC")->execute();
     foreach ($kills as $hO) {
         $data = $hO->toArray();
         unset($data['id'], $data['match_id'], $data['map_id']);
         $stats['rounds'][] = $data;
     }
     $kills = RoundSummaryTable::getInstance()->createQuery()->where("match_id = ?", $mO->getId())->orderBy("created_at ASC")->execute();
     foreach ($kills as $hO) {
         $data = $hO->toArray();
         unset($data['id'], $data['match_id'], $data['map_id']);
         $stats['summary'][] = $data;
     }
     return $this->renderText(json_encode($stats));
 }
 public function getPlayersKill()
 {
     return PlayerKillTable::getInstance()->createQuery()->where("round_id = ?", $this->getRoundId())->andWhere("map_id = ?", $this->getMapId())->orderBy("id ASC")->execute();
 }
 public function executeEntryKills(sfWebRequest $request)
 {
     $matchs = MatchsTable::getInstance()->findAll();
     $players = array();
     $players2 = array();
     $weapons = array();
     foreach ($matchs as $match) {
         $rounds = RoundSummaryTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->orderBy("round_id ASC")->execute();
         foreach ($rounds as $round) {
             $kill = PlayerKillTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->andWhere("round_id = ?", $round->getRoundId())->orderBy("created_at ASC")->limit(1)->fetchOne();
             if ($kill) {
                 $team = $kill->getKillerTeam() == "CT" ? "ct" : "t";
                 $team_killed = $kill->getKilledTeam() == "CT" ? "ct" : "t";
                 $weapons[$kill->getWeapon()]++;
                 if ($team == "ct" && $round->ct_win || $team == "t" && $round->t_win) {
                     @($players[$kill->getKiller()->getSteamId()]['name'] = $kill->getKillerName());
                     @$players[$kill->getKiller()->getSteamId()]['count']++;
                     @$players[$kill->getKiller()->getSteamId()]['weapons'][$kill->getWeapon()]++;
                 } else {
                     @($players[$kill->getKiller()->getSteamId()]['name'] = $kill->getKillerName());
                     @$players[$kill->getKiller()->getSteamId()]['loose']++;
                 }
                 @($players[$kill->getKiller()->getSteamId()]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB());
                 @($players2[$kill->getKilled()->getSteamId()]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB());
                 if ($team_killed == "ct" && $round->t_win || $team_killed == "t" && $round->ct_win) {
                     @($players2[$kill->getKilled()->getSteamId()]['name'] = $kill->getKilledName());
                     @$players2[$kill->getKilled()->getSteamId()]['count']++;
                 } else {
                     @($players2[$kill->getKilled()->getSteamId()]['name'] = $kill->getKilledName());
                     @$players2[$kill->getKilled()->getSteamId()]['loose']++;
                 }
                 $s = $kill->getKiller()->getTeam();
                 $name = "";
                 if ($s == "a") {
                     $name = $match->getTeamAName();
                 } elseif ($s == "b") {
                     $name = $match->getTeamBName();
                 }
                 if ($team == "ct" && $round->ct_win || $team == "t" && $round->t_win) {
                     @($teams[$name]['name'] = $name);
                     @$teams[$name]['count']++;
                 } else {
                     @($teams[$name]['name'] = $name);
                     @$teams[$name]['loose']++;
                 }
                 $name = "";
                 $s = $kill->getKilled()->getTeam();
                 if ($s == "a") {
                     $name = $match->getTeamAName();
                 } elseif ($s == "b") {
                     $name = $match->getTeamBName();
                 }
                 if ($team_killed == "ct" && $round->t_win || $team_killed == "t" && $round->ct_win) {
                     @($teams2[$name]['name'] = $name);
                     @$teams2[$name]['count']++;
                 } else {
                     @($teams2[$name]['name'] = $name);
                     @$teams2[$name]['loose']++;
                 }
                 @($teams[$name]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB());
                 @($teams2[$name]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB());
             }
         }
     }
     function cmp($a, $b)
     {
         if ($a['count'] == $b['count']) {
             return 0;
         }
         return $a['count'] > $b['count'] ? -1 : 1;
     }
     uasort($players, "cmp");
     uasort($players2, "cmp");
     uasort($teams, "cmp");
     uasort($teams2, "cmp");
     arsort($weapons);
     $this->playersWin = $players;
     $this->playersLoose = $players2;
     $this->teamsWin = $teams;
     $this->teamsLoose = $teams2;
     $this->weapons = $weapons;
 }
<?php

$players = array();
$statsRounds = array();
$rounds = RoundSummaryTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->orderBy("round_id ASC")->execute();
foreach ($rounds as $round) {
    $kill = PlayerKillTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->andWhere("round_id = ?", $round->getRoundId())->orderBy("created_at ASC")->limit(1)->fetchOne();
    if ($kill) {
        $team = $kill->getKillerTeam() == "CT" ? "ct" : "t";
        $team_killed = $kill->getKilledTeam() == "CT" ? "ct" : "t";
        $weapons[$kill->getWeapon()]++;
        if ($team == "ct" && $round->ct_win || $team == "t" && $round->t_win) {
            @($players[$kill->getKiller()->getSteamId()]['name'] = $kill->getKillerName());
            @$players[$kill->getKiller()->getSteamId()]['count']++;
            @$players[$kill->getKiller()->getSteamId()]['weapons'][$kill->getWeapon()]++;
            $statsRounds[$round->getRoundId()] = array("round" => $round, "kill" => $kill, "type" => "win");
        } else {
            @($players[$kill->getKiller()->getSteamId()]['name'] = $kill->getKillerName());
            @$players[$kill->getKiller()->getSteamId()]['loose']++;
            $statsRounds[$round->getRoundId()] = array("round" => $round, "kill" => $kill, "type" => "loose");
        }
        @($players[$kill->getKiller()->getSteamId()]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB());
        @($players2[$kill->getKilled()->getSteamId()]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB());
        if ($team_killed == "ct" && $round->t_win || $team_killed == "t" && $round->ct_win) {
            @($players2[$kill->getKilled()->getSteamId()]['name'] = $kill->getKilledName());
            @$players2[$kill->getKilled()->getSteamId()]['count']++;
        } else {
            @($players2[$kill->getKilled()->getSteamId()]['name'] = $kill->getKilledName());
            @$players2[$kill->getKilled()->getSteamId()]['loose']++;
        }
        $s = $kill->getKiller()->getTeam();