static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
<?php

require_once './hymnrepository.php';
header('Content-type/application-json');
try {
    $hymnid = $_GET['id'];
    $hymnRepository = hymnrepository::getInstance();
    $hymns = empty($hymnid) ? $hymnRepository->getAll() : $hymnRepository->getHymn($hymnid);
    echo json_encode($hymns, JSON_NUMERIC_CHECK);
} catch (Exception $e) {
    echo $e->getMessage();
}
Example #3
0
<?php

require_once './hymnrepository.php';
if (empty($_GET['id'])) {
    echo "Data missing.";
} else {
    $id = $_GET['id'];
    try {
        $db = hymnrepository::getInstance();
        $result = $db->deleteHymn($id);
        echo $result;
    } catch (Exception $e) {
        throw new Exception($e->getMessage());
    }
}