            %%[[if preview]]%%
            <span>preview</span>
        %%[[endif]]%%
%%[[if publish]]%%
    <?php
     if (strlen(session_id()) < 1) {
session_start();
}
require '%relativeSiteAssetPath%/sc_assets/Database.php';
require '%relativeSiteAssetPath%/sc_assets/Post.php';
$_SESSION['db_name'] = '%relativeSiteAssetPath%/sc_assets/db/calendar.db';
//include_once '%relativeSiteAssetPath%/sc_assets/logging.php';
        //passing record id in url
        if(isset($_GET['cid'])) {
            $myid = $_GET['cid'];
            } else {
                 _log('Retreive Record: No Record ID Was Passed');
                    //echo    $myid = '**URL pram FAIL**/';
                    }
                    
                    // Instantiate DB & connect
                     $database = new Database();
                     $db = $database->connect();

                     // Instantiate post object
                     $post = new Post($db);
                      $query = "SELECT * FROM  `events2` WHERE `id` =  ' $myid' ";
                        _log('Retreive Query is:'.$query);

                    $stmt = $db->prepare($query);

                            $stmt->execute();
                                $fetch = $stmt->fetch();
                                

/*                                
                                $database = new Database();
$db = $database->connect();

if (!$db) {
    die("Failed to connect to database");
}

if (!$db->querySingle('SELECT 1 FROM `sqlite_master` LIMIT 1;')) {
    // There are no tables in the database, so the connection is closed
    $db->close();
    $db = $database->connect();
}

// Instantiate post object
$post = new Post($db);
$query = "SELECT * FROM `events2` WHERE `id` = '$myid'";
_log('Retrieve Query is: '.$query);

$stmt = $db->prepare($query);
$stmt->execute();
$fetch = $stmt->fetch();
*/

        ?>
%%[[endif]]%%
