Skip to content

Commit 002bb13

Browse files
committed
Fix for status api by correcting sql queries
1 parent 58b3751 commit 002bb13

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

api/status.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@
1515
$array = $constellation->render_status(true, false);
1616
echo json_encode($array);
1717
}else{
18-
$queryId = $mysqli->prepare("SELECT id as 'id' from services where id = ?;");
18+
// get id of service, check if service exists
19+
$queryId = $mysqli->prepare("SELECT id from services where id = ?;");
1920
$queryId->bind_param("i", $_GET['id']);
2021
$queryId->execute();
2122
$result = $queryId->get_result()->fetch_assoc();
2223
if (!count($result))
2324
{
2425
die(json_encode(["error" => _("Service does not exist!")]));
2526
}
26-
27+
// get name, description and status.type (status of service) by id
2728
$query = $mysqli->prepare("select services.id, name, description, status.type from services inner join status on status.id = services.id where services.id = ?;");
2829
$query->bind_param("i", $_GET['id']);
2930
$query->execute();
3031
$result = $query->get_result()->fetch_assoc();
31-
32+
// if type is a number then return it, else just return the service name/desc
3233
if (is_numeric($result["type"])) {
3334
$service = new Service($_GET["id"], $result["name"], $result["description"], '', $result["type"]);
3435
} else {

0 commit comments

Comments
 (0)