Ejemplo n.º 1
0
    // collect action to determine what to call
    $action = $_POST['action'];
    // collect dataType to return
    $dataType = $_POST['dataType'];
    // no longer needed, and don't want it added to queries
    unset($_POST['action']);
    unset($_POST['dataType']);
    switch ($action) {
        case 'add':
        case 'insert':
        case 'save':
        case 'update':
            $confirmation = $connection->save($_POST);
            break;
        case 'delete':
            $confirmation = $connection->delete($_POST);
            break;
        default:
            // get
            $confirmation = $connection->get($_POST);
    }
    // return JSON results if specified
    if ($dataType && strtolower($dataType) === 'json') {
        $confirmation = json_encode($confirmation);
    }
    die($confirmation);
    // return for ajax calls
} else {
    // get list of countries for form
    $params = ['table' => 'countries', 'orderBy' => 'title'];
    $confirmation = $connection->get($params);
Ejemplo n.º 2
0
 function remove($id)
 {
     $db = new DB_connection();
     return $db->delete(config::TABLENAME, $id);
 }