2021-09-13 18:03:20 +01:00
|
|
|
<?php
|
2021-12-28 21:22:32 +00:00
|
|
|
namespace api;
|
|
|
|
use PDO;
|
|
|
|
|
2021-09-13 18:03:20 +01:00
|
|
|
require_once "./config.php";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TimelineData class
|
|
|
|
* Define all functions which either get, update, create or delete timeline data
|
|
|
|
*/
|
2021-12-28 21:22:32 +00:00
|
|
|
class timelineData
|
2021-09-13 18:03:20 +01:00
|
|
|
{
|
2022-10-09 02:40:06 +01:00
|
|
|
/**
|
|
|
|
* Get all education data
|
|
|
|
* @return array - Array of all education data or error message
|
|
|
|
*/
|
2022-07-29 20:00:36 +01:00
|
|
|
function getEduData(): array
|
2021-09-13 18:03:20 +01:00
|
|
|
{
|
|
|
|
$conn = dbConn();
|
2022-10-09 23:32:50 +01:00
|
|
|
$stmt = $conn->prepare("SELECT ID, startPeriod, endPeriod, grade, course FROM edu ORDER BY startPeriod DESC;");
|
2021-09-13 18:03:20 +01:00
|
|
|
$stmt->execute();
|
|
|
|
|
|
|
|
// set the resulting array to associative
|
|
|
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
{
|
|
|
|
return $result;
|
|
|
|
}
|
2022-07-29 20:00:36 +01:00
|
|
|
return array("errorMessage" => "Error, edu data not found");
|
2021-09-13 18:03:20 +01:00
|
|
|
}
|
|
|
|
|
2022-10-09 02:40:06 +01:00
|
|
|
/**
|
|
|
|
* Get all work data
|
|
|
|
* @return array - Array of all work data or error message
|
|
|
|
*/
|
2022-07-29 20:00:36 +01:00
|
|
|
function getWorkData(): array
|
2021-09-13 18:03:20 +01:00
|
|
|
{
|
|
|
|
$conn = dbConn();
|
2022-10-09 16:02:07 +01:00
|
|
|
$stmt = $conn->prepare("SELECT startPeriod, endPeriod, companyName, area, title FROM work ORDER BY work.startPeriod DESC;");
|
2021-09-13 18:03:20 +01:00
|
|
|
$stmt->execute();
|
|
|
|
|
|
|
|
// set the resulting array to associative
|
|
|
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
{
|
|
|
|
return $result;
|
|
|
|
}
|
2022-07-29 20:00:36 +01:00
|
|
|
return array("errorMessage" => "Error, work data not found");
|
2021-09-13 18:03:20 +01:00
|
|
|
}
|
2022-10-09 23:32:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update education data
|
|
|
|
* @param string $dateFrom - Start date
|
|
|
|
* @param string $dateTo - End date
|
|
|
|
* @param string $grade - Grade
|
|
|
|
* @param string $course - Course
|
|
|
|
* @param string $id - ID of the education data
|
|
|
|
* @return bool - True if successful, false if not
|
|
|
|
*/
|
|
|
|
function updateEduData(string $dateFrom, string $dateTo, string $grade, string $course, string $id): bool
|
|
|
|
{
|
|
|
|
$conn = dbConn();
|
|
|
|
$stmt = $conn->prepare("UPDATE edu SET startPeriod = :dateFrom, endPeriod = :dateTo, grade = :grade, course = :course WHERE ID = :id;");
|
|
|
|
$stmt->bindParam(":dateFrom", $dateFrom);
|
|
|
|
$stmt->bindParam(":dateTo", $dateTo);
|
|
|
|
$stmt->bindParam(":grade", $grade);
|
|
|
|
$stmt->bindParam(":course", $course);
|
|
|
|
$stmt->bindParam(":id", $id);
|
|
|
|
return $stmt->execute();
|
|
|
|
}
|
|
|
|
|
2021-12-28 21:22:32 +00:00
|
|
|
}
|