// Calcul de la VMA estimée sur la meilleure des 5 dernières courses
$bestVmaVal = 0;
$bestRaceName = "";
$bestRaceSpeed = 0;
$bestRaceDistance = 0;
$bestRaceTime = "";
$bestRaceDate = "";
$age = 0;
if (!empty($coId)) {
if (!empty($dateNaissance) && is_numeric($dateNaissance) && $dateNaissance > 0) {
$age = intval($year) - (int)$dateNaissance;
}
$stmtRaces = $cnx->prepare("
SELECT * FROM participation
WHERE co_id = ? AND pa_min > 0 AND pa_min < 699 AND cr_id LIKE ?
ORDER BY cr_id DESC LIMIT 5
");
$stmtRaces->execute([$coId, $year . '%']);
$latestRaces = $stmtRaces->fetchAll(PDO::FETCH_ASSOC);
if (!empty($latestRaces)) {
foreach ($latestRaces as $racePart) {
$crIdLong = $racePart['cr_id'];
$min = (int)$racePart['pa_min'];
$sec = (int)$racePart['pa_sec'];
$dist = getDistanceForParticipation($cnx, $crIdLong);
$totalSec = ($min * 60) + $sec;
if ($totalSec > 0 && $dist > 0) {
$speed = $dist / ($totalSec / 3600);
$vmaEst = estimateVmaFromPerformance($dist, $min, $sec);
if ($vmaEst > $bestVmaVal) {
$bestVmaVal = $vmaEst;
$bestRaceSpeed = $speed;
$bestRaceDistance = $dist;
$bestRaceTime = $min . ":" . ($sec < 10 ? "0" : "") . $sec;
$baseId = substr((string)$crIdLong, 0, 6) . "0";
$stmtC = $cnx->prepare("SELECT cr_nom, cr_date FROM course WHERE cr_id = ?");
$stmtC->execute([$baseId]);
$cRow = $stmtC->fetch(PDO::FETCH_ASSOC);
if ($cRow) {
$bestRaceName = $t->m8($cRow['cr_nom']);
$bestRaceDate = $cRow['cr_date'];
} else {
$yearVal = substr((string)$crIdLong, 0, 4);
$num = intval(substr((string)$crIdLong, 4, 2));
$stmtH = $cnx->prepare("SELECT nom, date_course FROM courseHistory WHERE annee = ? AND course_num = ?");
$stmtH->execute([$yearVal, $num]);
$cHRow = $stmtH->fetch(PDO::FETCH_ASSOC);
if ($cHRow) {
$bestRaceName = $t->m8($cHRow['nom']);
$bestRaceDate = $cHRow['date_course'];
} else {
$bestRaceName = "Course #" . $crIdLong;
$bestRaceDate = "";
}
}
}
}
}
}
}
?>
Fiche Athlète
BURTON Jonathan
Né(e) en 1981
Genre : Homme