prepare("SELECT * FROM kngil.sp_use_history(?, ?, ?)"); $stmt->execute([ $p_member_id, $p_user_nm, $p_dept_nm ]); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // 3. W2UI를 위해 각 행에 'recid' 필드 주입 $records = []; foreach ($rows as $index => $row) { // user_id와 sq_no 조합으로 유일키 생성 (권장) // 만약 데이터가 없을 경우를 대비해 $index를 활용할 수도 있음 $row['recid'] = ($row['user_id'] ?? 'unknown') . '_' . ($row['sq_no'] ?? $index); $records[] = $row; } // 4. 결과 출력 echo json_encode($records, JSON_UNESCAPED_UNICODE); // 한글 깨짐 방지 } catch (PDOException $e) { http_response_code(500); echo json_encode(['status' => 'error', 'message' => $e->getMessage()]); } ?>