prepare($query); $stmt->execute(); $chat_history = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt = null; $query = null; return $chat_history; }