mirror of
https://github.com/Alvin-Zilverstand/pokedex.git
synced 2026-03-06 11:07:31 +01:00
Add user Pokémon relationships table and improve error handling in competitors data fetching
This commit is contained in:
@@ -97,3 +97,11 @@ CREATE TABLE IF NOT EXISTS pokemon_egg_groups (
|
||||
FOREIGN KEY (pokemon_id) REFERENCES pokemon(id),
|
||||
FOREIGN KEY (egg_group_id) REFERENCES egg_groups(id)
|
||||
);
|
||||
|
||||
-- Table to store user Pokémon relationships
|
||||
CREATE TABLE IF NOT EXISTS user_pokemon (
|
||||
user_id INT NOT NULL,
|
||||
pokemon_id INT NOT NULL,
|
||||
PRIMARY KEY (user_id, pokemon_id),
|
||||
FOREIGN KEY (pokemon_id) REFERENCES pokemon(id)
|
||||
);
|
||||
|
||||
@@ -35,15 +35,21 @@ try {
|
||||
logMessage("Executing query: $sql");
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$competitors = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$competitors[] = $row;
|
||||
}
|
||||
if ($result === false) {
|
||||
throw new Exception("Query failed: " . $conn->error);
|
||||
}
|
||||
|
||||
$competitors = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$competitors[] = $row;
|
||||
}
|
||||
|
||||
if (empty($competitors)) {
|
||||
logMessage("No competitors data found.");
|
||||
echo json_encode(["error" => "No competitors data found"]);
|
||||
} else {
|
||||
logMessage("Query result: " . json_encode($competitors));
|
||||
echo json_encode($competitors);
|
||||
} else {
|
||||
throw new Exception("Error executing query: " . $conn->error);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
logMessage("Exception: " . $e->getMessage());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
:root {
|
||||
--identity-primary: #dc0a2d;
|
||||
--identity-primary: #0394fc;
|
||||
|
||||
--grayscale-dark: #212121;
|
||||
--grayscale-medium: #666666;
|
||||
|
||||
Reference in New Issue
Block a user