示例#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 TodoItem class
include 'todoClass.php';
if ($data) {
    $item = new TodoItem($data);
    if ($method != '') {
        switch ($method) {
            case 'setName':
                $sth = $item->write('name', $item->name);
                break;
            case 'setCheck':
                $sth = $item->write('check', $item->check);
                break;
            case 'updatePosition':
                $sth = $item->updatePosition();
                break;
            case 'create':
                $sth = $item->create();
                break;
            case 'delete':
                $sth = $item->delete();
                break;
        }
        if ($method == 'getLast') {