beginTransaction(); $sql = "UPDATE " . $DB . "." . $tablename . " SET orderdate = ?, towhom = ?, reply = ?, deadline = ?, work_status = ?, title = ?, first_writer = ?, update_log = ?, searchtag = ?, itemsep = ? WHERE num = ? LIMIT 1"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $orderdate, PDO::PARAM_STR); $stmh->bindValue(2, $towhom, PDO::PARAM_STR); $stmh->bindValue(3, $reply, PDO::PARAM_STR); $stmh->bindValue(4, $deadline, PDO::PARAM_STR); $stmh->bindValue(5, $work_status, PDO::PARAM_STR); $stmh->bindValue(6, $title, PDO::PARAM_STR); $stmh->bindValue(7, $first_writer, PDO::PARAM_STR); $stmh->bindValue(8, $update_log, PDO::PARAM_STR); $stmh->bindValue(9, $searchtag, PDO::PARAM_STR); $stmh->bindValue(10, $itemsep, PDO::PARAM_STR); $stmh->bindValue(11, $num, PDO::PARAM_INT); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); echo json_encode(["error" => $Exception->getMessage()], JSON_UNESCAPED_UNICODE); exit; } } if ($mode == "insert" || $mode == '' || $mode == null) { $update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . " "; try { $pdo->beginTransaction(); $sql = "INSERT INTO " . $DB . "." . $tablename . " ( orderdate, towhom, reply, deadline, work_status, title, first_writer, update_log, searchtag, itemsep ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $orderdate, PDO::PARAM_STR); $stmh->bindValue(2, $towhom, PDO::PARAM_STR); $stmh->bindValue(3, $reply, PDO::PARAM_STR); $stmh->bindValue(4, $deadline, PDO::PARAM_STR); $stmh->bindValue(5, $work_status, PDO::PARAM_STR); $stmh->bindValue(6, $title, PDO::PARAM_STR); $stmh->bindValue(7, $first_writer, PDO::PARAM_STR); $stmh->bindValue(8, $update_log, PDO::PARAM_STR); $stmh->bindValue(9, $searchtag, PDO::PARAM_STR); $stmh->bindValue(10, $itemsep, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); echo json_encode(["error" => $Exception->getMessage()], JSON_UNESCAPED_UNICODE); exit; } } if ($mode == "delete") { try { $pdo->beginTransaction(); $sql = "UPDATE " . $DB . "." . $tablename . " SET is_deleted=1 WHERE num = ?"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $num, PDO::PARAM_INT); $stmh->execute(); $pdo->commit(); } catch (PDOException $ex) { $pdo->rollBack(); echo json_encode(["error" => $ex->getMessage()], JSON_UNESCAPED_UNICODE); exit; } } $data = [ 'num' => $num, 'title' => $title, 'orderdate' => $orderdate, 'mode' => $mode ]; echo json_encode($data, JSON_UNESCAPED_UNICODE); ?>