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