日期:2013-09-09  浏览次数:20470 次

    {
        $this->doXmlString2Xml($string,$xpath);
    }

    /**
    * Adds an additional pear::db_result resultset to $this->xmldoc
    *
    * @param    Object db_result result from a DB-query
    * @see      doSql2Xml()
    * @access   public
    */
    function addResult($result)
    {
        $this->doSql2Xml($result);
    }

    /**
    * Adds an aditional resultset generated from an sql-statement
    *  to $this->xmldoc
    *
    * @param    string sql a string containing an sql-statement.
    * @access   public
    * @see      doSql2Xml()
    */
    function addSql($sql)
    {
        /* if there are {} expressions in the sql query, we assume it's an xpath expression to
        *   be evaluated.
        */

        if (preg_match_all ("/\{([^\}]+)\}/i",$sql,$matches))
        {
            foreach ($matches[1] as $match)
            {
                $sql = preg_replace("#\{".preg_quote($match)."\}#  ", $this->getXpathValue($match),$sql);
            }
        }
        $result = $this->db->query($sql);

        //very strange
        if (PEAR::isError($result->result)) {
                 print "You have an SQL-Error:<br>".$result->result->userinfo;
                 print "<br>";
                new DB_Error($result->result->code,PEAR_ERROR_DIE);
        }

        $this->doSql2Xml($result);
    }

    /**
    * Adds an aditional resultset generated from an Array
    *  to $this->xmldoc
    * TODO: more explanation, how arrays are transferred
    *
    * @param    array multidimensional array.
    * @access   public
    * @see      doArray2Xml()
    */
    function addArray ($array)
    {
        $parent_row =