prepare($sql); $stmh->bindValue(1,$num,PDO::PARAM_STR); $stmh->execute(); $row = $stmh->fetch(PDO::FETCH_ASSOC); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } try{ $pdo->beginTransaction(); $sql = "update " . $DB . ".almember set name=?, part=?, dateofentry=?, referencedate=?, availableday=?, comment=?, company=? "; $sql .= " where num=? LIMIT 1"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $name, PDO::PARAM_STR); $stmh->bindValue(2, $part, PDO::PARAM_STR); $stmh->bindValue(3, $dateofentry, PDO::PARAM_STR); $stmh->bindValue(4, $referencedate, PDO::PARAM_STR); $stmh->bindValue(5, $availableday, PDO::PARAM_STR); $stmh->bindValue(6, $comment, PDO::PARAM_STR); $stmh->bindValue(7, $company, PDO::PARAM_STR); $stmh->bindValue(8, $num, PDO::PARAM_STR); //고유키값이 같나?의 의미로 ?로 num으로 맞춰야 합니다. where 구문 $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } if ($mode=="insert"){ try{ $pdo->beginTransaction(); $sql = "insert into " . $DB . ".almember(name, part, dateofentry, referencedate, availableday, comment, company) "; $sql .= " values(?, ?, ?, ?, ?, ?, ?) "; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $name, PDO::PARAM_STR); $stmh->bindValue(2, $part, PDO::PARAM_STR); $stmh->bindValue(3, $dateofentry, PDO::PARAM_STR); $stmh->bindValue(4, $referencedate, PDO::PARAM_STR); $stmh->bindValue(5, $availableday, PDO::PARAM_STR); $stmh->bindValue(6, $comment, PDO::PARAM_STR); $stmh->bindValue(7, $company, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } if ($mode=="delete"){ try{ $pdo->beginTransaction(); $sql = "delete from " . $DB . ".almember where num = ?"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1,$num,PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } //각각의 정보를 하나의 배열 변수에 넣어준다. $data = array( "dateofentry" => $dateofentry, "company" => $company, "mode" => $mode, ); //json 출력 echo(json_encode($data, JSON_UNESCAPED_UNICODE)); ?>