Skip to content

Commit

Permalink
Fix for status api by correcting sql queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen-MLR committed Apr 22, 2021
1 parent 58b3751 commit 002bb13
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@
$array = $constellation->render_status(true, false);
echo json_encode($array);
}else{
$queryId = $mysqli->prepare("SELECT id as 'id' from services where id = ?;");
// get id of service, check if service exists
$queryId = $mysqli->prepare("SELECT id from services where id = ?;");
$queryId->bind_param("i", $_GET['id']);
$queryId->execute();
$result = $queryId->get_result()->fetch_assoc();
if (!count($result))
{
die(json_encode(["error" => _("Service does not exist!")]));
}

// get name, description and status.type (status of service) by id
$query = $mysqli->prepare("select services.id, name, description, status.type from services inner join status on status.id = services.id where services.id = ?;");
$query->bind_param("i", $_GET['id']);
$query->execute();
$result = $query->get_result()->fetch_assoc();

// if type is a number then return it, else just return the service name/desc
if (is_numeric($result["type"])) {
$service = new Service($_GET["id"], $result["name"], $result["description"], '', $result["type"]);
} else {
Expand Down

0 comments on commit 002bb13

Please sign in to comment.