- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
// /bending/fetch_bending_detail.php (신규 파일)
|
|
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$num = $_POST['num'] ?? 0;
|
|
|
|
if (empty($num)) {
|
|
echo json_encode(['error' => '부품 번호가 없습니다.']);
|
|
exit;
|
|
}
|
|
|
|
$pdo = db_connect();
|
|
|
|
try {
|
|
$sql = "SELECT
|
|
num as source_num,
|
|
itemName,
|
|
material,
|
|
widthsum,
|
|
imgdata,
|
|
inputList,
|
|
bendingrateList,
|
|
sumList,
|
|
colorList,
|
|
AList
|
|
FROM {$DB}.bending
|
|
WHERE num = ? AND is_deleted IS NULL
|
|
LIMIT 1";
|
|
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute([$num]);
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($result) {
|
|
// JSON 배열들을 파싱
|
|
$result['inputList'] = json_decode($result['inputList'], true) ?: [];
|
|
$result['bendingrateList'] = json_decode($result['bendingrateList'], true) ?: [];
|
|
$result['sumList'] = json_decode($result['sumList'], true) ?: [];
|
|
$result['colorList'] = json_decode($result['colorList'], true) ?: [];
|
|
$result['AList'] = json_decode($result['AList'], true) ?: [];
|
|
|
|
echo json_encode($result, JSON_UNESCAPED_UNICODE);
|
|
} else {
|
|
echo json_encode(['error' => '해당 부품을 찾을 수 없습니다.']);
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo json_encode(['error' => '데이터베이스 조회 중 오류가 발생했습니다.']);
|
|
}
|
|
?>
|