beginTransaction(); $sql = "update " . $DB . "." . $table . " set " . $field . "=? "; $sql .= " where num=? LIMIT 1"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $strtmp, PDO::PARAM_STR); $stmh->bindValue(2, $recnum, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } // delete인 경우 if($command=='delete') { try{ $pdo->beginTransaction(); $sql = "delete from " . $DB . "." . $table . " where num = ? " ; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $recnum, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } // insert인 경우 if($command=='insert') { try{ $pdo->beginTransaction(); $sql = "insert into " . $DB . "." . $table . " (" . $field . ") " ; $sql .= " values(?) "; $stmh = $pdo->prepare($sql); $stmh->bindValue(1,$strtmp,PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } //각각의 정보를 하나의 배열 변수에 넣어준다. $data = array( "command" => $command, "recnum" => $recnum, "field" => $field, "table" => $table, "strtmp" => $strtmp, ); //json 출력 echo(json_encode($data, JSON_UNESCAPED_UNICODE)); ?>