= :fuse_dt::date AND a.use_dt::date <= :tuse_dt::date ORDER BY a.use_dt DESC, a.sq_no DESC "; $stmt = $pdo->prepare($sql); // 파라미터 바인딩 (이름 기반 바인딩이 더 직관적입니다) $stmt->execute([ ':member_id' => $p_member_id, ':user_nm' => $p_user_nm, ':dept_nm' => $p_dept_nm, ':fuse_dt' => $p_fuse_dt, ':tuse_dt' => $p_tuse_dt ]); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // 3. W2UI용 recid 가공 $records = []; foreach ($rows as $index => $row) { $row['recid'] = $row['user_id'] . '_' . ($row['sq_no'] ?? $index); $records[] = $row; } echo json_encode($records, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK); } catch (PDOException $e) { error_log("DB Error: " . $e->getMessage()); http_response_code(500); echo json_encode(['status' => 'error', 'message' => $e->getMessage()], JSON_UNESCAPED_UNICODE); } ?>