From e2db8f25a47dc337c0715335133646741e170f89 Mon Sep 17 00:00:00 2001 From: vista-man <524715@vistacollege.nl> Date: Thu, 27 Mar 2025 12:01:11 +0100 Subject: [PATCH] =?UTF-8?q?Refactor=20logging=20messages=20for=20Pok=C3=A9?= =?UTF-8?q?mon=20queries=20and=20ensure=20JSON=20data=20is=20returned=20wi?= =?UTF-8?q?thout=20additional=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2/get-pokemon.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/v2/get-pokemon.php b/v2/get-pokemon.php index 0e3e9c5..2561e7c 100644 --- a/v2/get-pokemon.php +++ b/v2/get-pokemon.php @@ -48,7 +48,7 @@ if (isset($_GET['id'])) { LEFT JOIN stats st ON p.id = st.pokemon_id WHERE p.id = $id GROUP BY p.id"; - logMessage("Executing query: $sql"); + logMessage("Executing query for Pokémon ID: $id"); $result = $conn->query($sql); if ($result === false) { @@ -61,8 +61,7 @@ if (isset($_GET['id'])) { $pokemon = $result->fetch_assoc(); $pokemon['types'] = $pokemon['types'] ? explode(',', $pokemon['types']) : []; $pokemon['abilities'] = $pokemon['abilities'] ? explode(',', $pokemon['abilities']) : []; - logMessage("Query result: " . json_encode($pokemon)); - echo json_encode($pokemon); + echo json_encode($pokemon); // Only return JSON data } else { logMessage("No Pokémon found for ID: $id"); echo json_encode(["error" => "No Pokémon found"]); @@ -70,7 +69,7 @@ if (isset($_GET['id'])) { } else { // Handle requests without an 'id' parameter $sql = "SELECT id, name, height, weight, base_experience, image_url FROM pokemon"; - logMessage("Executing query: $sql"); + logMessage("Executing query to fetch all Pokémon"); $result = $conn->query($sql); if ($result === false) { @@ -84,8 +83,7 @@ if (isset($_GET['id'])) { $pokemons[] = $row; } - logMessage("Query result: " . json_encode($pokemons)); - echo json_encode($pokemons); + echo json_encode($pokemons); // Only return JSON data } $conn->close();