static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
require_once './visitor_repository.php';
require_once './visitor.class.php';
if (empty($_POST['notes']) || empty($_POST['name'])) {
    echo "You must provide your name and comment.";
} else {
    /* actual post data */
    $visitor->notes = $_POST['notes'];
    $visitor->name = $_POST['name'];
    $visitor->email = $_POST['email'];
    $visitor->phone = $_POST['phone'];
    $visitor->address = $_POST['address'];
    /* mock test data */
    /*
    echo 'Using mock data. <br/>';
    $visitor->notes = 'Sample notes';
    $visitor->name = 'Sherebyah Tisbi';
    $visitor->email = '*****@*****.**';
    $visitor->phone = '347-841-4356';
    $visitor->address = '37 Washington Square Circle, Washington, NJ 07882';
    */
    try {
        echo 'Creating visitor repository. <br/>';
        $db = visitor_repository::getInstance();
        echo 'Repository created. <br/>';
        $result = $db->Add($visitor);
        echo $result;
    } catch (Exception $e) {
        throw new Exception($e->getMessage());
    }
}