<?php
header('Content-Type: application/json');

// get parameters from client
$writingID = $_POST["writingID"];


include "./../lib/json_builder.php";
include "./../lib/connect_db.php";

$jsonBuilder = new JsonBuilder();
$dbConnector = new DBConnector();

$isConnected = $dbConnector->connectDB();
if (!$isConnected) {
	$jsonBuilder->setErrorMessage("DB connection : failed");
	$jsonBuilder->sendResultFail();
	exit;
}


include "./../db/db_method_container.php";
include "./../db/writing_collection.php";

$writingCollection = new WritingCollection($dbConnector->getMysqli());
$writingInfo = $writingCollection->getWritingInfo($writingID);

// $jsonBuilder->setData("name", $writingInfo["name"]);
// $jsonBuilder->setData("filename", $writingInfo["filename"]);
// $jsonBuilder->setData("writer", $writingInfo["writer"]);
// $jsonBuilder->setData("writerID", $writingInfo["writerID"]);
$jsonBuilder->setData("writingInfo", $writingInfo);
$jsonBuilder->sendResultSuccess();
?>