function update_11_12($db, $dbtype) { if ($dbtype == 'mysql') { $db->ex("ALTER TABLE todolist ADD `duedate` DATE default NULL"); } else { $db->ex("ALTER TABLE todolist ADD duedate DATE default NULL"); } # Fixing broken tags $db->ex("BEGIN"); $db->ex("DELETE FROM tags"); $db->ex("DELETE FROM tag2task"); $q = $db->dq("SELECT id,tags FROM todolist"); while ($r = $q->fetch_assoc()) { if ($r['tags'] == '') { continue; } $tag_ids = prepare_tags($r['tags']); if ($tag_ids) { update_task_tags($r['id'], $tag_ids); } } $db->ex("COMMIT"); }
$t['total'] = 0; if ($title == '') { echo json_encode($t); exit; } $tags = trim(_post('tags')); $db->ex("BEGIN"); $tag_ids = prepare_tags($tags, $listId); $cur_ids = get_task_tags($id); if ($cur_ids) { $ids = implode(',', $cur_ids); $db->ex("DELETE FROM tag2task WHERE task_id={$id}"); $db->dq("UPDATE tags SET tags_count=tags_count-1 WHERE id IN ({$ids})"); } if ($tag_ids) { update_task_tags($id, $tag_ids); } if (is_null($duedate)) { $duedate = 'NULL'; } else { $duedate = $db->quote($duedate); } $db->dq("UPDATE todolist SET title=?,note=?,prio=?,tags=?,duedate={$duedate} WHERE id={$id}", array($title, $note, $prio, $tags)); $db->ex("COMMIT"); $r = $db->sqa("SELECT * FROM todolist WHERE id={$id}"); if ($r) { $t['list'][] = prepareTaskRow($r); $t['total'] = 1; } echo json_encode($t); exit;