commit
This commit is contained in:
27
kngil/bbs/adm_product_popup.php
Normal file
27
kngil/bbs/adm_product_popup.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// 1. DB 연결 (절대 경로 혹은 상대 경로 확인)
|
||||
require_once 'db_conn.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
// 2. 프로시저 호출 (컬럼명: itm_cd, itm_nm, area, itm_amt 등)
|
||||
$stmt = $pdo->prepare("SELECT * FROM kngil.sp_item_r()");
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// 3. W2UI를 위해 각 행에 'recid' 필드 강제 주입
|
||||
$records = [];
|
||||
foreach ($rows as $row) {
|
||||
$row['recid'] = $row['itm_cd']; // 상품코드를 고유 키로 지정
|
||||
$records[] = $row;
|
||||
}
|
||||
|
||||
// 4. 순수 JSON만 출력 (다른 echo나 공백이 섞이면 에러 발생)
|
||||
echo json_encode($records);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// 에러 발생 시 그리드가 이해할 수 있게 JSON으로 출력
|
||||
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user