예제 #1
0
<?php

include_once 'config.php';
$data = $_POST['data'];
$method = $_POST['method'];
$user_id = (include_once 'user.php');
$data = (array) json_decode($data);
$data['user_id'] = $user_id;
// Connect TodoList class
include 'todoClass.php';
if ($data) {
    $list = new TodoList($data);
    if ($method != '') {
        switch ($method) {
            case 'setName':
                $sth = $list->write('name', $list->name);
                break;
            case 'setDeadline':
                $sth = $list->write('deadline', $list->deadline);
                break;
            case 'create':
                $sth = $list->create();
                break;
            case 'delete':
                $sth = $list->delete();
                break;
        }
        if ($method == 'getLast') {
            echo $list->getLast($db);
            return false;
        }