Location: PHPKode > projects > FiForms Framework > FiForms/FiForms-includes/FiReports_CSVReport.inc.php
<?php
/*
*******************************************************************************
    
    FiReport -- Rapid XML Report Generator
    Copyright (C) 2004  Daniel McFeeters

    included with
    
    FiForms -- A collection of PHP classes designed 
    to facilitate rapid development of web-database software

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


    The original author of this library can be contacted at the following 
    address:

    Daniel McFeeters
    182 Baker Rd.
    Faubush, KY 42544-6526
    email:databases [at] fiforms [dot] org
    http://www.fiforms.org/


Project Started January 27, 2004
*******************************************************************************
FiForms_FiReportCSV.inc.php
*******************************************************************************
*/

require_once("FiReports_FiReport.inc.php");

class FiReportCSV extends FiReport
{
    function FiReportCSV()
    {
        $this->FiReport();
        $this->mimetype = "text/csv";
    }

    function appendDataSet($queryset,$passedString)
    {
        $resource = @mysql_query(
            $this->parQuery($queryset->sql),
            $this->connections[$queryset->connectid]->link);
        $firstRow = TRUE;
        while($rowArray = @mysql_fetch_array($resource,MYSQL_ASSOC))
        {
            if($firstRow)
            {
                foreach($rowArray as $fieldName => $fieldValue)
                {
                    $this->docString .= '"'.$fieldName.'",';
                }
                $firstRow = FALSE;
                $this->docString .= "\n";
            }
            $currentString = $passedString;
            foreach($rowArray as $fieldValue)
            {
                $currentString .= '"'.$fieldValue.'",';
            }

            if(isset($queryset->subQueries))
            {
               $this->appendDataSet($queryset->subQueries[1],$currentString);
            }
            else
            {
              $this->docString .= $currentString;
              $this->docString .= "\n";
            }  

        }  // while rowArray
    } // function appendDataSet

    function getDocString()
    {
        $this->makeConnections();
        foreach($this->queryset as $thisQuery)
        {
            $this->appendDataSet($thisQuery,"");
        }    
    } // function returnXML

} // class FiReportXML 
?>
Return current item: FiForms Framework