} if ($review["strengths"] == "") { $review["strengths"] = NULL; } if ($review["weaknesses"] == "") { $review["weaknesses"] = NULL; } // echo "<!-- Begin the transaction and lock the database. -->\n"; $app->beginTransaction(); // echo "<!-- Get the audience ID from the database. -->\n"; require 'model/audiences.php'; $audience = getAudience($review); $review["audience_id"] = $audience["audience_id"]; // echo "<!-- Check the genre and insert it in the database if it's a new one. -->\n"; require 'model/genres.php'; $genre = getGenreByName($review["genre"]); if ($genre == NULL) { insertGenre($review["genre"]); $genre["genre_id"] = $app->lastInsertId(); } $review["genre_id"] = $genre["genre_id"]; // echo "<!-- Check the game and insert it in the database if it's a new one. -->\n"; // echo "<!-- game: " . $review["game"] . " -->"; require 'model/games.php'; $game = getGameByName($review["game"]); // echo "<!-- $game: " . $game . " -->"; if ($game == NULL) { // echo "<!-- The game doesn't exist. -->"; insertGame($review["game"]); // echo "<!-- Game inserted with success. -->\n"; $game["game_id"] = $app->lastInsertId();
echo "<!-- Check that we have the same number of entries for each category -->"; if (sizeof($new_likes) != $num || sizeof($new_genres) != $num || sizeof($new_comments) != $num) { $_SESSION["error_msg"] = "All fields are required"; header('location: /app/admin/?action=view_survey'); exit; } echo "<!-- Begin the transaction and lock the database. -->\n"; $app->beginTransaction(); require '../model/links.php'; require '../model/genres.php'; require '../model/features.php'; require '../model/comments.php'; for ($i = 0; $i < $num; $i++) { echo "<!-- Check the genre and insert it in the database if it's new. -->\n"; echo "<!-- Genre: " . $new_genres[$i] . " -->"; $genres[$i] = getGenreByName($new_genres[$i]); if ($genres[$i] == NULL) { insertGenre($new_genres[$i]); $genres[$i]["genre_id"] = $app->lastInsertId(); } echo "<!-- Link genre with game -->"; if (checkGamesGenres($game_id, $genres[$i]["genre_id"]) == NULL) { linkGamesGenres($game_id, $genres[$i]["genre_id"]); } echo "<!-- Check the feature and insert it in the database if it's new. -->\n"; echo "<!-- Feature: " . $new_features[$i] . " -->"; if ($new_features[$i] != "none") { $features[$i]["feature_id"] = 0; $features[$i]["not_like_it"] = 0; $features[$i]["like_it"] = 0; $features[$i] = getFeatureByName($new_features[$i]);