Class iam_csvdump

Description

IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download.

  • version:

    1.0

    IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download.

    Browser and OS detection for appropriate handling of download and EOL chars.

    Requires PHP v 4.0+ and MySQL 3.23+. Some portions taken from the CSV_UTIL_CLASS by Andrej Arn <andrej@blueshoes.org>.

    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details.

  • author: Iván Ariel Melgrati <mailto:phpclasses@imelgrat.mailshell.com>

Located in /iam_csvdump.php (line 30)


	
			
Method Summary
String arrayToCsvString (Array $array, [String $separator = ';'], [String $trim = 'both'], [Boolean $removeEmptyLines = TRUE])
void dump (String $query_string, [String $filename = "dump"], [mixed $ext = "csv"], [String $dbname = "mysql"], [String $user = "root"], [String $password = ""], [String $host = "localhost"], String $extension)
void _db_connect ([String $dbname = "mysql"], [String $user = "root"], [String $password = ""], [String $host = "localhost"])
String _define_newline ()
void _generate_csv (String $query_string, [String $dbname = "mysql"], [String $user = "root"], [String $password = ""], [String $host = "localhost"])
String _get_browser_type ()
String _get_mime_type ()
String _valToCsvHelper (String $val, String $separator, Mixed $trimFunction)
Methods
arrayToCsvString (line 44)

Takes an array and creates a csv string from it.

  • return: A CSV String. It returns an empty string if there Array is empty (NULL)
  • todo: Add param "fill to fit max length"?
  • access: public
String arrayToCsvString (Array $array, [String $separator = ';'], [String $trim = 'both'], [Boolean $removeEmptyLines = TRUE])
  • Array $array: (see below)
  • String $separator: Field separator ()default is ';')
  • String $trim: If the cells should be trimmed , default is 'both'. It can also be 'left', 'right' or 'both'. 'none' makes it faster since omits many function calls.
  • Boolean $removeEmptyLines: (default is TRUE. removes "lines" that have no value, would come out empty.)
dump (line 263)

Generate the CSV File and send it to browser or download it as a file

  • access: public
void dump (String $query_string, [String $filename = "dump"], [mixed $ext = "csv"], [String $dbname = "mysql"], [String $user = "root"], [String $password = ""], [String $host = "localhost"], String $extension)
  • String $query_string: An SQL statement (usually a SELECT statement)
  • String $filename: Filename to use when downloading the File. Default="dump". If set to "", the dump is displayed on the browser.
  • String $extension: Extension to use when downloading the File. Default="csv"
  • String $dbname: Name of the Database to use
  • String $user: User to Access the Database
  • String $password: Password to Access the Database
  • String $host: Name of the Host holding the DB
_db_connect (line 206)

Generates a CSV File from an SQL String (and outputs it to the browser)

  • access: private
void _db_connect ([String $dbname = "mysql"], [String $user = "root"], [String $password = ""], [String $host = "localhost"])
  • String $dbname: Name of the Database
  • String $user: User to Access the Database
  • String $password: Password to Access the Database
  • String $host: Name of the Host holding the DB
_define_newline (line 126)

Define EOL character according to target OS

  • return: A String containing the End Of Line Sequence corresponding to the client's OS
  • access: private
String _define_newline ()
_generate_csv (line 230)

Generates a CSV File from an SQL String (and outputs it to the browser)

  • access: private
void _generate_csv (String $query_string, [String $dbname = "mysql"], [String $user = "root"], [String $password = ""], [String $host = "localhost"])
  • String $query_string: An SQL statement (usually a SELECT statement)
  • String $dbname: Name of the Database
  • String $user: User to Access the Database
  • String $password: Password to Access the Database
  • String $host: Name of the Host holding the DB
_get_browser_type (line 151)

Define the client's browser type

  • return: A String containing the Browser's type or brand
  • access: private
String _get_browser_type ()
_get_mime_type (line 188)

Define MIME-TYPE according to target Browser

  • return: A string containing the MIME-TYPE String corresponding to the client's browser
  • access: private
String _get_mime_type ()
_valToCsvHelper (line 96)

Works on a string to include in a csv string.

String _valToCsvHelper (String $val, String $separator, Mixed $trimFunction)
  • String $val
  • String $separator
  • Mixed $trimFunction: If the cells should be trimmed , default is 'both'. It can also be 'left', 'right' or 'both'. 'none' makes it faster since omits many function calls.

Documentation generated on Fri, 12 Dec 2003 18:43:03 -0300 by phpDocumentor 1.2.3