Topic: access to $forum_db after hook ps_parse_message_post_merge

Trying to create a tag that will list all topics linked to a tag. Anyway need access to the database to query some tables, but the $forum_db object is not available after this hook 'ps_parse_message_post_merge'

Any solution?

 $return = ($hook = get_hook('ps_parse_message_end')) ? eval($hook) : null;
        //hacknow
        function taglist_create($matches)
        {
                $taglistq = $matches[1];
                $idresult = "";

                $idquery = array(
                                                'SELECT'        =>      'id',
                                                'FROM'          =>      'tags',
                                                'WHERE'         =>      "tags.tag = '".$taglistq."'"
                );

                var_dump($forum_db);

                $taglistname = preg_replace("/^hidetag/","",$matches[1]);
                $content = "<strong>List based on tag: $taglistname</strong><ul><li>Lol</li></ul>";
                return $content;
        }
        $text =  preg_replace_callback("/[\[]taglist=([^\]]+?)[\]]/","taglist_create",$text);