54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
namespace api;
|
|
use PDO;
|
|
|
|
require_once "./config.php";
|
|
|
|
/**
|
|
* TimelineData class
|
|
* Define all functions which either get, update, create or delete timeline data
|
|
*/
|
|
class timelineData
|
|
{
|
|
/**
|
|
* Get all education data
|
|
* @return array - Array of all education data or error message
|
|
*/
|
|
function getEduData(): array
|
|
{
|
|
$conn = dbConn();
|
|
$stmt = $conn->prepare("SELECT DATE_FORMAT(startPeriod, '%b, %Y') as startPeriod, DATE_FORMAT(endPeriod, '%b, %Y') as endPeriod, grade, course FROM edu ORDER BY startPeriod DESC;");
|
|
$stmt->execute();
|
|
|
|
// set the resulting array to associative
|
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($result)
|
|
{
|
|
return $result;
|
|
}
|
|
return array("errorMessage" => "Error, edu data not found");
|
|
}
|
|
|
|
/**
|
|
* Get all work data
|
|
* @return array - Array of all work data or error message
|
|
*/
|
|
function getWorkData(): array
|
|
{
|
|
$conn = dbConn();
|
|
$stmt = $conn->prepare("SELECT DATE_FORMAT(startPeriod, '%b, %Y') as startPeriod, DATE_FORMAT(endPeriod, '%b, %Y') as endPeriod, companyName, area, title FROM work ORDER BY work.startPeriod DESC;");
|
|
$stmt->execute();
|
|
|
|
// set the resulting array to associative
|
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($result)
|
|
{
|
|
return $result;
|
|
}
|
|
return array("errorMessage" => "Error, work data not found");
|
|
}
|
|
|
|
}
|