prepare( "SELECT codigo_unico, estado FROM unidades_inventario WHERE producto_id = :product_id AND sede_id = :sede_id" ); $stmt->bindParam(':product_id', $productId, PDO::PARAM_INT); $stmt->bindParam(':sede_id', $sedeId, PDO::PARAM_INT); $stmt->execute(); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode($results); } catch (PDOException $e) { http_response_code(500); echo json_encode(['error' => 'Database error: ' . $e->getMessage()]); } ?>