"Comment", "fields" => [ "name" => Type::string(), "comment" => Type::string(), "gravatarURL" => Type::string(), "id" => Type::int() ], ]); function comments($article, $conn) { $response = []; $result = $conn->query("SELECT * FROM comments WHERE article='$article'"); while ($row = $result->fetch_assoc()) { $commentElement = [ "name" => $row["name"], "comment" => $row["comment"], "gravatarURL" => get_gravatar($row["email"]), "id" => $row["id"] ]; array_push($response, $commentElement); } return $response; }