beginTransaction(); // SQL 쿼리 생성 (삽입) $sql = "INSERT INTO {$DB}.{$tablename} (reg_date, lot_number, author, workplacename, remark, search_tag) "; $sql .= "VALUES (?, ?, ?, ?, '', ?)"; $stmh = $pdo->prepare($sql); $reg_date = date('Y-m-d'); // 현재 날짜 $search_tag = $lot_number . ' ' . $outworkplace . ' ' . $user_name; // 검색 태그 생성 // 변수 바인딩 $stmh->bindValue(1, $reg_date, PDO::PARAM_STR); $stmh->bindValue(2, $lot_number, PDO::PARAM_STR); $stmh->bindValue(3, $user_name, PDO::PARAM_STR); $stmh->bindValue(4, $outworkplace, PDO::PARAM_STR); $stmh->bindValue(5, $search_tag, PDO::PARAM_STR); // 실행 $stmh->execute(); $pdo->commit(); // 결과 반환 (JSON 형식) echo json_encode(['lotNum' => 'KD-' . $pairCode . '-' . $lot_number]); } catch (PDOException $Exception) { $pdo->rollBack(); echo json_encode(['error' => $Exception->getMessage()]); } ?>