Files
sam-kd/output/fetch_estimate_process.php

41 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
// Assuming $DB is defined in mydb.php or session.php
if (!isset($DB)) {
$DB = 'chandj'; // 실제 데이터베이스 이름으로 대체하세요.
}
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();
// estimateIdList가 배열로 전달되는지 확인
$estimateIdList = $_POST['estimateIdList'];
if (is_array($estimateIdList)) {
try {
// estimateIdList 내의 ID들을 사용하여 데이터베이스에서 일치하는 항목을 모두 가져옴
$inQuery = implode(',', array_fill(0, count($estimateIdList), '?'));
$sql = "SELECT num, pjnum, secondord, model_name, outworkplace, orderman, secondordmantel, estimateList, estimateSlatList, itemradio
FROM {$DB}.estimate WHERE num IN ($inQuery) AND (is_deleted IS NULL or is_deleted ='0') ";
$stmh = $pdo->prepare($sql);
// 각 ID를 바인딩
foreach ($estimateIdList as $index => $id) {
$stmh->bindValue(($index+1), $id, PDO::PARAM_INT);
}
$stmh->execute();
$estimateDetails = $stmh->fetchAll(PDO::FETCH_ASSOC);
// 데이터를 JSON 형식으로 반환
header('Content-Type: application/json');
echo json_encode($estimateDetails);
} catch (PDOException $e) {
echo json_encode(['error' => '데이터를 가져오는 중 오류가 발생했습니다: ' . $e->getMessage()]);
}
} else {
echo json_encode(['error' => '유효하지 않은 데이터 요청입니다.']);
}
?>