Example #1
0
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') {
            echo $item->getLast($db);
            return false;
        }
        if (!$db->exec($sth)) {
            echo "Error width {$sth}";
            return false;
        } else {
            echo "success {$method}";
        }