$ingredientId = $_GET["id"]; $ingredient = ingredientTypeQuery::create()->findPk($ingredientId); } $force = false; if (array_key_exists("force", $_GET)) { $force = $_GET["force"]; } if (isset($ingredient)) { try { $databaseName = unitPeer::DATABASE_NAME; $constraints = array("ingredient" => "ingredientId"); if ($force == true) { ForeignService::forceForeignConstraints($databaseName, $constraints, $ingredientId, true); $ingredient->delete(); http_response_code(204); } else { $result = ForeignService::verifyForeignConstraints($databaseName, $constraints, $ingredientId); if ($result) { $ingredient->delete(); http_response_code(204); } else { echo json_encode(array("result" => "Cet ingredient est référencée dans les ingredients de recette.")); } } } catch (PropelException $ex) { http_response_code(500); } } else { http_response_code(404); } });
$countryId = $_GET["id"]; $country = countryQuery::create()->findPk($countryId); } $force = false; if (array_key_exists("force", $_GET)) { $force = $_GET["force"]; } if (isset($country)) { try { $databaseName = countryPeer::DATABASE_NAME; $constraints = array("recipes" => "origin"); if ($force == true) { ForeignService::forceForeignConstraints($databaseName, $constraints, $countryId); $country->delete(); http_response_code(204); } else { $result = ForeignService::verifyForeignConstraints($databaseName, $constraints, $countryId); if ($result) { $country->delete(); http_response_code(204); } else { echo json_encode(array("result" => "Ce pays est référencé par des recettes.")); } } } catch (PropelException $ex) { http_response_code(500); } } else { http_response_code(404); } });