최초 커밋
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// ⭐️ 여기에 추가!
|
||||
$product_code = $_POST['product_code'] ?? '';
|
||||
$family_version = $_POST['family_version'] ?? '';
|
||||
$external_version = $_POST['external_version'] ?? '';
|
||||
|
||||
$conn = new mysqli('localhost', 'egbim', 'baron3840!!', 'egbim');
|
||||
if ($conn->connect_error) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['message' => 'DB 연결 실패: ' . $conn->connect_error]);
|
||||
exit;
|
||||
}
|
||||
mysqli_set_charset($conn, 'utf8mb4');
|
||||
|
||||
// FK 에러 방지: products 테이블에 존재하는지 확인
|
||||
$chk = $conn->prepare("SELECT COUNT(*) FROM products WHERE code=?");
|
||||
$chk->bind_param("s", $product_code);
|
||||
$chk->execute();
|
||||
$chk->bind_result($cnt);
|
||||
$chk->fetch();
|
||||
$chk->close();
|
||||
if ($cnt < 1) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['message' => '존재하지 않는 제품코드입니다']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 실제 insert/update 쿼리 실행
|
||||
$sql = "INSERT INTO deploy_versions (product_code, family_version, external_version)
|
||||
VALUES (?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
family_version=VALUES(family_version),
|
||||
external_version=VALUES(external_version)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
if (!$stmt) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['message' => '쿼리 준비 오류: ' . $conn->error]);
|
||||
exit;
|
||||
}
|
||||
$stmt->bind_param("sss", $product_code, $family_version, $external_version);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['message' => '저장 완료']);
|
||||
} else {
|
||||
http_response_code(500);
|
||||
echo json_encode(['message' => 'DB 오류: ' . $stmt->error]);
|
||||
}
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user