Beispiel #1
0
                array_push($response["posts"], $tmp3);
            }
        } while ($post = $result->fetch_assoc());
        $response["message"] = "Query Successful";
    } else {
        $response["error"] = true;
        $response["message"] = "One or more field(s) missing or invalid.";
    }
    echoResponse(200, $response);
});
$app->get('/getpostbyid', function () use($app) {
    $response = array();
    $postId = $app->request()->get('postId');
    $db = new DbHandler();
    // fetching all user tasks
    $result = $db->getPostById($postId);
    if ($result) {
        $response["error"] = false;
        $response["posts"] = array();
        $response["comments"] = array();
        // looping through result and preparing updates array
        //        while ($update = $result->fetch_assoc()) {
        $post = $result->fetch_assoc();
        $tmp = array();
        $tmp["id"] = $post["id"];
        $tmp["locationId"] = $post["locationId"];
        $tmp["posterId"] = $post["posterId"];
        $tmp["posterName"] = $post["username"];
        $tmp["postType"] = $post["type"];
        $tmp["description"] = $post["description"];
        $tmp["likeCount"] = $post["likeCount"];