$con = \Propel\Runtime\Propel::getConnection(); if (!array_key_exists("game", $_GET) || !array_key_exists("platform", $_GET)) { header("Location: /"); /* Redirect browser */ exit; } else { $con->beginTransaction(); $game = GameQuery::create()->filterByName($_GET["game"])->findOne($con); $platform = PlatformQuery::create()->filterByName($_GET["platform"])->findOne($con); if ($game == null || $platform == null) { header("Location: /"); /* Redirect browser */ exit; } } $header = RatingHeaderQuery::create()->filterByGame($game)->filterByPlatform($platform)->findOne($con); $categories = CategoryQuery::create()->orderBySequence()->find($con); $options = CategoryOptionQuery::create()->orderBySequence()->find($con); if (array_key_exists("rating_submit", $_POST)) { try { if ($header == null) { $header = new RatingHeader(); $header->setGame($game); $header->setPlatform($platform); $header->setCreated(new DateTime()); $header->save($con); } else { RatingValueQuery::create()->filterByRatingHeader($header)->delete($con); } $score = 0; RatingValueQuery::create()->filterByRatingHeader($header)->delete($con);