my-portfolio/src/api/timelineData.php

46 lines
1.3 KiB
PHP
Raw Normal View History

2021-08-22 10:44:49 +01:00
<?php
namespace api;
use PDO;
2021-08-23 21:38:37 +01:00
require_once "./config.php";
2021-08-22 10:44:49 +01:00
/**
* TimelineData class
* Define all functions which either get, update, create or delete timeline data
*/
class timelineData
2021-08-22 10:44:49 +01:00
{
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();
2021-08-22 10:44:49 +01:00
// set the resulting array to associative
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($result)
{
return $result;
}
return array("errorMessage" => "Error, edu data not found");
}
function getWorkData(): array
{
$conn = dbConn();
2021-09-06 19:20:44 +01:00
$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");
}
}