header('Content-Type: application/json');
require_once '../model/SimpleTableManager.php';
require_once '../model/FormSubmitManager.php';
$tableManager = new SimpleTableManager();
$errors = array();
// array to hold validation errors
$data = array();
// array to pass back data
$tableName = FormSubmit::POST("table");
$crudType = FormSubmit::POST("crud-type");
/*
$tableName = FormSubmit::GET("table");
$crudType = FormSubmit::GET("crud-type");
*/
$tableManager = new SimpleTableManager();
$tableManager->Initialize($tableName);
$tableManager->debug = true;
//$tableManager::set("originalName", "POON");
if (isset($_POST["create"])) {
    foreach ($_POST["create"] as $key => $value) {
        if (isset($_POST["createDate"])) {
            if (!array_key_exists($key, $_POST["createDate"])) {
                $tableManager->{$key} = $value;
            }
        } else {
            $tableManager->{$key} = $value;
        }
    }
}
if (isset($_POST["createDate"])) {
<?php

header('Content-Type: application/json');
require_once '../model/SimpleTableManager.php';
require_once '../model/FormSubmitManager.php';
$tableManager = new SimpleTableManager();
$errors = array();
// array to hold validation errors
$data = array();
// array to pass back data
$tableName = FormSubmit::POST("table");
$crudType = FormSubmit::POST("crud-type");
$tableManager = new SimpleTableManager();
$tableManager->Initialize($tableName);
$tableManager->debug = true;
if (isset($_POST["updateTo"])) {
    foreach ($_POST["updateTo"] as $key => $value) {
        $tableManager->{$key} = $value;
    }
}
echo json_encode($tableManager->update());
//echo json_encode($tableManager->getTablePrimaryKey())
<?php

header('Content-Type: application/json');
require_once '../model/SimpleTableManager.php';
require_once '../model/FormSubmitManager.php';
$tableManager = new SimpleTableManager();
$errors = array();
// array to hold validation errors
$data = array();
// array to pass back data
if (isset($_GET["table"])) {
    $tableName = $_GET["table"];
}
if (isset($_POST["table"])) {
    $tableName = $_POST["table"];
}
//$tableName = FormSubmit::POST("table");
$crudType = FormSubmit::POST("crud-type");
$tableManager = new SimpleTableManager();
$tableManager->Initialize($tableName);
$tableManager->debug = true;
//var_dump($_POST);
//$tableManager::set("originalName", "POON");
if (isset($_POST["read"])) {
    foreach ($_POST["read"] as $key => $value) {
        $tableManager->{$key} = $value;
    }
}
echo json_encode($tableManager->select());