diff --git a/app/model/Partie.php b/app/model/Partie.php index 698819acd8d2b4dcb1ee78c662f08eba8495eac1..0f043c3020132b6ec32def1d07f7d0ebcfc37279 100644 --- a/app/model/Partie.php +++ b/app/model/Partie.php @@ -117,8 +117,19 @@ class Partie extends Model foreach ($joueur as $kj => $j) { if ($stmt3->execute(array(":id_joueur" => $j->slug, ":id_jeu" => $jeu->slug))) { if ($row = $stmt3->fetch()) { + if(!is_null($row[0])){ // Le joueur a déja joué à ce jeu $old_score_e[$k][$kj] = $row[0]; + } + else{ + // ou le joueur n'a jamais joué à ce jeu, on je rajoute à la relation. + $old_score_e[$k][$kj] = 1000; + $stmtN = $db->prepare($sqlN); + if ($stmtN->execute(array(":id_joueur" => $j->slug, ":id_jeu" => $jeu->slug, ":score" => 1000))) { + + } else + return 2; + } } else { // ou le joueur n'a jamais joué à ce jeu, on je rajoute à la relation. $old_score_e[$k][$kj] = 1000; @@ -135,8 +146,19 @@ class Partie extends Model // récupération du score actuel de chaque joueur if ($stmt3->execute(array(":id_joueur" => $joueur->slug, ":id_jeu" => $jeu->slug))) { if ($row = $stmt3->fetch()) { + if(!is_null($row[0])){ // Le joueur a déja joué à ce jeu $old_score[$k] = $row[0]; + } + else{ + // ou le joueur n'a jamais joué à ce jeu, on je rajoute à la relation. + $old_score[$k] = 1000; + $stmtN = $db->prepare($sqlN); + if ($stmtN->execute(array(":id_joueur" => $joueur->slug, ":id_jeu" => $jeu->slug, ":score" => 1000))) { + + } else + return 2; + } } else { // ou le joueur n'a jamais joué à ce jeu, on je rajoute à la relation. $old_score[$k] = 1000;