beginTransaction(); $sql = "update " . $DB . "." . $tablename . " set subject=?, content=?, is_html=?, noticecheck=?, searchtext=? where num=?"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $subject, PDO::PARAM_STR); $stmh->bindValue(2, $content, PDO::PARAM_LOB); $stmh->bindValue(3, $is_html, PDO::PARAM_STR); $stmh->bindValue(4, $noticecheck, PDO::PARAM_STR); $stmh->bindValue(5, $searchtext, PDO::PARAM_STR); $stmh->bindValue(6, $num, PDO::PARAM_INT); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: " . $Exception->getMessage(); } } else { if ($is_html == "y") { $content = htmlspecialchars($content); } try { $pdo->beginTransaction(); $sql = "insert into " . $DB . "." . $tablename . " (id, name, subject, content, regist_day, hit, is_html, noticecheck, searchtext) "; $sql .= "values(?, ?, ?, ?, now(), 0, ?, ?, ?)"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $_SESSION["userid"], PDO::PARAM_STR); $stmh->bindValue(2, $_SESSION["name"], PDO::PARAM_STR); $stmh->bindValue(3, $subject, PDO::PARAM_STR); $stmh->bindValue(4, $content, PDO::PARAM_LOB); $stmh->bindValue(5, $is_html, PDO::PARAM_STR); $stmh->bindValue(6, $noticecheck, PDO::PARAM_STR); $stmh->bindValue(7, $searchtext, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: " . $Exception->getMessage(); } } if ($mode != "modify") { // 신규데이터인경우 num을 추출한 후 view로 보여주기 $sql = "select * from " . $DB . "." . $tablename . " order by num desc limit 1"; try { $stmh = $pdo->query($sql); $rowNum = $stmh->rowCount(); $row = $stmh->fetch(PDO::FETCH_ASSOC); $num = $row["num"]; } catch (PDOException $Exception) { print "오류: " . $Exception->getMessage(); } // 신규데이터인 경우 첨부파일/첨부이미지 추가한 것이 있으면 parentid 변경해줌 // 신규데이터인경우 num을 추출한 후 view로 보여주기 try{ $pdo->beginTransaction(); $sql = "update ".$DB.".picuploads set parentnum=? where parentnum=? "; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $num, PDO::PARAM_STR); $stmh->bindValue(2, $timekey, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } $data = [ 'num' => $num, 'tablename' => $tablename ]; echo json_encode($data, JSON_UNESCAPED_UNICODE); ?>