Esempio n. 1
0
        $location = $_POST['location'] or die('ubicació no informada');
        $observations = isset($_POST['observations']) ? $_POST['observations'] : '';
        $comments = isset($_POST['comments']) ? $_POST['comments'] : '';
        $group = array('id' => $id, 'name' => $name, 'age' => $age, 'date_start' => $date_start, 'date_end' => $date_end, 'location' => $location, 'comments' => $comments, 'observations' => $observations);
}
/*
echo 'action: '.$action;
echo '$group';
print_r($group);
*/
$c = new Connection();
$conn = $c->getConnection();
$groupDAO = new GroupDAO($conn);
switch ($action) {
    case 'new':
        $insert_id = $groupDAO->create($group);
        break;
    case 'update':
        $groupDAO->update($group);
        break;
    case 'delete':
        //echo 'delete dao'.$id; exit;
        $groupDAO->delete($id);
        break;
}
if ($isAjax) {
    echo json_encode($response);
    exit;
} else {
    header("Location: " . $siteUrl . "/group_list.php?r=" . mt_rand(0, 9999999));
}