add some more stuff
This commit is contained in:
parent
886a54001e
commit
03dc793863
103
api.php
103
api.php
@ -230,13 +230,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
|
||||
if($actionin == "getallsources"){
|
||||
$stmt13 = $mysqliconn->prepare("SELECT ID, PublicationID, Place, CreatorID FROM Sources;");
|
||||
$stmt13->execute();
|
||||
$stmt13->bind_result($id, $publicationid, $place, $creatorid);
|
||||
$stmt13->store_result();
|
||||
$stmt17 = $mysqliconn->prepare("SELECT ID, PublicationID, Place, CreatorID FROM Sources;");
|
||||
$stmt17->execute();
|
||||
$stmt17->bind_result($id, $publicationid, $place, $creatorid);
|
||||
$stmt17->store_result();
|
||||
$outarr = array();
|
||||
if ($stmt13->num_rows > 0){
|
||||
while ($stmt13->fetch()){
|
||||
if ($stmt17->num_rows > 0){
|
||||
while ($stmt17->fetch()){
|
||||
$tmparr["id"] = $id;
|
||||
$tmparr["publicationid"] = $publicationid;
|
||||
$tmparr["place"] = $place;
|
||||
@ -321,9 +321,100 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
function processAuthorRelated($actionin, mysqli $mysqliconn){
|
||||
|
||||
if($actionin == "createauthor"){
|
||||
$stmt16 = $mysqliconn->prepare("INSERT INTO Authors (AuthorName, CreatorID) VALUES (?, ?);");
|
||||
$authorname = htmlspecialchars($_POST["authorname"]);
|
||||
$cruid = $_SESSION["userID"];
|
||||
$stmt16->bind_param("si", $authorname, $cruid);
|
||||
$stmt16->execute();
|
||||
$stmt16->store_result();
|
||||
}
|
||||
|
||||
if($actionin == "getallauthors"){
|
||||
$stmt18 = $mysqliconn->prepare("SELECT ID, AuthorName, CreatorID FROM Authors;");
|
||||
$stmt18->execute();
|
||||
$stmt18->bind_result($id, $authorname, $creatorid);
|
||||
$stmt18->store_result();
|
||||
$outarr = array();
|
||||
if ($stmt18->num_rows > 0){
|
||||
while ($stmt18->fetch()){
|
||||
$tmparr["id"] = $id;
|
||||
$tmparr["authorname"] = $authorname;
|
||||
$tmparr["creatorid"] = $creatorid;
|
||||
array_push($outarr, $tmparr);
|
||||
}
|
||||
}
|
||||
return json_encode($outarr);
|
||||
}
|
||||
|
||||
if($actionin == "getallauthorsbycreator"){
|
||||
$stmt19 = $mysqliconn->prepare("SELECT ID, AuthorName, CreatorID FROM Authors WHERE CreatorID = ?;");
|
||||
$cruid = intval($_POST['creatorid']);
|
||||
$stmt19->bind_param("i", $cruid);
|
||||
$stmt19->execute();
|
||||
$stmt19->bind_result($id, $authorname, $creatorid);
|
||||
$stmt19->store_result();
|
||||
$outarr = array();
|
||||
if ($stmt19->num_rows > 0){
|
||||
while ($stmt19->fetch()){
|
||||
$tmparr["id"] = $id;
|
||||
$tmparr["authorname"] = $authorname;
|
||||
$tmparr["creatorid"] = $creatorid;
|
||||
array_push($outarr, $tmparr);
|
||||
}
|
||||
}
|
||||
return json_encode($outarr);
|
||||
}
|
||||
|
||||
}
|
||||
function processPublicationRelated($actionin, mysqli $mysqliconn){
|
||||
if($actionin == "createpublication"){
|
||||
$stmt20 = $mysqliconn->prepare("INSERT INTO Publications (PublicationName, AuthorID, CreatorID) VALUES (?, ?, ?);");
|
||||
$publicationname = htmlspecialchars($_POST["publicationname"]);
|
||||
$authorid = intval($_POST['authorid']);
|
||||
$cruid = $_SESSION["userID"];
|
||||
$stmt20->bind_param("sii", $publicationname, $authorid, $cruid);
|
||||
$stmt20->execute();
|
||||
$stmt20->store_result();
|
||||
}
|
||||
|
||||
if($actionin == "getallpublications"){
|
||||
$stmt21 = $mysqliconn->prepare("SELECT ID, PublicationName, AuthorID, CreatorID FROM Publications;");
|
||||
$stmt21->execute();
|
||||
$stmt21->bind_result($id, $publicationname, $authorid, $creatorid);
|
||||
$stmt21->store_result();
|
||||
$outarr = array();
|
||||
if ($stmt21->num_rows > 0){
|
||||
while ($stmt21->fetch()){
|
||||
$tmparr["id"] = $id;
|
||||
$tmparr["publicationname"] = $publicationname;
|
||||
$tmparr["authorid"] = $authorid;
|
||||
$tmparr["creatorid"] = $creatorid;
|
||||
array_push($outarr, $tmparr);
|
||||
}
|
||||
}
|
||||
return json_encode($outarr);
|
||||
}
|
||||
|
||||
if($actionin == "getallpublicationsbycreator"){
|
||||
$stmt22 = $mysqliconn->prepare("SELECT ID, PublicationName, AuthorID, CreatorID FROM Publications WHERE CreatorID = ?;");
|
||||
$cruid = intval($_POST['creatorid']);
|
||||
$stmt22->bind_param("i", $cruid);
|
||||
$stmt22->execute();
|
||||
$stmt22->bind_result($id, $publicationname, $authorid, $creatorid);
|
||||
$stmt22->store_result();
|
||||
$outarr = array();
|
||||
if ($stmt22->num_rows > 0){
|
||||
while ($stmt22->fetch()){
|
||||
$tmparr["id"] = $id;
|
||||
$tmparr["publicationname"] = $publicationname;
|
||||
$tmparr["authorid"] = $authorid;
|
||||
$tmparr["creatorid"] = $creatorid;
|
||||
array_push($outarr, $tmparr);
|
||||
}
|
||||
}
|
||||
return json_encode($outarr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user