Location: PHPKode > scripts > IAM CSV Dump > iam-csv-dump/docs/iam_csvdump/iam_csvdump.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>Docs For Class iam_csvdump</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
			<div class="page-body">			
<h2 class="class-name">Class iam_csvdump</h2>

<a name="sec-description"></a>
<div class="info-box">
	<div class="info-box-title">Description</div>
	<div class="nav-bar">
					<span class="disabled">Description</span> |
															<a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
						
			</div>
	<div class="info-box-body">
		<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download.</p>
	<ul class="tags">
				<li><span class="field">version:</span> <p>1.0</p><p>IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download.</p><p>Browser and OS detection for appropriate handling of download and EOL chars.</p><p>Requires PHP v 4.0+ and MySQL 3.23+. Some portions taken from the CSV_UTIL_CLASS by Andrej Arn &lt;hide@address.com&gt;.</p><p>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.</p><p>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.</p></li>
				<li><span class="field">author:</span> Iván Ariel Melgrati &lt;<a href="mailto:hide@address.com">mailto:hide@address.com</a>&gt;</li>
			</ul>
		<p class="notes">
			Located in <a class="field" href="_CSVDump_iam_csvdump_php.html">/iam_csvdump.php</a> (line <span class="field"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a30">30</a></span>)
		</p>
		
		        
		<pre></pre>
	
			</div>
</div>



	<a name="sec-method-summary"></a>
	<div class="info-box">
		<div class="info-box-title">Method Summary</span></div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
									<span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
		</div>
		<div class="info-box-body">			
			<div class="method-summary">
								
				<div class="method-definition">
											<span class="method-result">String</span>
										<a href="#arrayToCsvString" title="details" class="method-name">arrayToCsvString</a>
											(<span class="var-type">Array</span>&nbsp;<span class="var-name">$array</span>, [<span class="var-type">String</span>&nbsp;<span class="var-name">$separator</span> = <span class="var-default">';'</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$trim</span> = <span class="var-default">'both'</span>], [<span class="var-type">Boolean</span>&nbsp;<span class="var-name">$removeEmptyLines</span> = <span class="var-default">TRUE</span>])
									</div>
								
				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#dump" title="details" class="method-name">dump</a>
											(<span class="var-type">String</span>&nbsp;<span class="var-name">$query_string</span>, [<span class="var-type">String</span>&nbsp;<span class="var-name">$filename</span> = <span class="var-default">"dump"</span>], [<span class="var-type">mixed</span>&nbsp;<span class="var-name">$ext</span> = <span class="var-default">"csv"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$dbname</span> = <span class="var-default">"mysql"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$user</span> = <span class="var-default">"root"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$password</span> = <span class="var-default">""</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$host</span> = <span class="var-default">"localhost"</span>], <span class="var-type">String</span>&nbsp;<span class="var-name">$extension</span>)
									</div>
								
				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#_db_connect" title="details" class="method-name">_db_connect</a>
											([<span class="var-type">String</span>&nbsp;<span class="var-name">$dbname</span> = <span class="var-default">"mysql"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$user</span> = <span class="var-default">"root"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$password</span> = <span class="var-default">""</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$host</span> = <span class="var-default">"localhost"</span>])
									</div>
								
				<div class="method-definition">
											<span class="method-result">String</span>
										<a href="#_define_newline" title="details" class="method-name">_define_newline</a>
										()
									</div>
								
				<div class="method-definition">
											<span class="method-result">void</span>
										<a href="#_generate_csv" title="details" class="method-name">_generate_csv</a>
											(<span class="var-type">String</span>&nbsp;<span class="var-name">$query_string</span>, [<span class="var-type">String</span>&nbsp;<span class="var-name">$dbname</span> = <span class="var-default">"mysql"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$user</span> = <span class="var-default">"root"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$password</span> = <span class="var-default">""</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$host</span> = <span class="var-default">"localhost"</span>])
									</div>
								
				<div class="method-definition">
											<span class="method-result">String</span>
										<a href="#_get_browser_type" title="details" class="method-name">_get_browser_type</a>
										()
									</div>
								
				<div class="method-definition">
											<span class="method-result">String</span>
										<a href="#_get_mime_type" title="details" class="method-name">_get_mime_type</a>
										()
									</div>
								
				<div class="method-definition">
											<span class="method-result">String</span>
										<a href="#_valToCsvHelper" title="details" class="method-name">_valToCsvHelper</a>
											(<span class="var-type">String</span>&nbsp;<span class="var-name">$val</span>, <span class="var-type">String</span>&nbsp;<span class="var-name">$separator</span>, <span class="var-type">Mixed</span>&nbsp;<span class="var-name">$trimFunction</span>)
									</div>
							</div>
		</div>
	</div>		

	
	<a name="sec-methods"></a>
	<div class="info-box">
		<div class="info-box-title">Methods</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
													<a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)
						
		</div>
		<div class="info-box-body">
			<A NAME='method_detail'></A>
<a name="methodarrayToCsvString" id="arrayToCsvString"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<span class="method-title">arrayToCsvString</span> (line <span class="line-number"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a44">44</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Takes an array and creates a csv string from it.</p>
	<ul class="tags">
				<li><span class="field">return:</span> A CSV String. It returns an empty string if there Array is empty (NULL)</li>
				<li><span class="field">todo:</span> Add param &quot;fill to fit max length&quot;?</li>
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">String</span>
		<span class="method-name">
			arrayToCsvString
		</span>
					(<span class="var-type">Array</span>&nbsp;<span class="var-name">$array</span>, [<span class="var-type">String</span>&nbsp;<span class="var-name">$separator</span> = <span class="var-default">';'</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$trim</span> = <span class="var-default">'both'</span>], [<span class="var-type">Boolean</span>&nbsp;<span class="var-name">$removeEmptyLines</span> = <span class="var-default">TRUE</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">Array</span>
				<span class="var-name">$array</span><span class="var-description">: (see below)</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$separator</span><span class="var-description">: Field separator ()default is ';')</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$trim</span><span class="var-description">: 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.</span>			</li>
					<li>
				<span class="var-type">Boolean</span>
				<span class="var-name">$removeEmptyLines</span><span class="var-description">: (default is TRUE. removes &quot;lines&quot; that have no value, would come out empty.)</span>			</li>
				</ul>
		
		
	</div>
<a name="methoddump" id="dump"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<span class="method-title">dump</span> (line <span class="line-number"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a263">263</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Generate the CSV File and send it to browser or download it as a file</p>
	<ul class="tags">
				<li><span class="field">access:</span> public</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			dump
		</span>
					(<span class="var-type">String</span>&nbsp;<span class="var-name">$query_string</span>, [<span class="var-type">String</span>&nbsp;<span class="var-name">$filename</span> = <span class="var-default">"dump"</span>], [<span class="var-type">mixed</span>&nbsp;<span class="var-name">$ext</span> = <span class="var-default">"csv"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$dbname</span> = <span class="var-default">"mysql"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$user</span> = <span class="var-default">"root"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$password</span> = <span class="var-default">""</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$host</span> = <span class="var-default">"localhost"</span>], <span class="var-type">String</span>&nbsp;<span class="var-name">$extension</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$query_string</span><span class="var-description">: An SQL statement (usually a SELECT statement)</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$filename</span><span class="var-description">: Filename to use when downloading the File. Default=&quot;dump&quot;. If set to &quot;&quot;, the dump is displayed on the browser.</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$extension</span><span class="var-description">: Extension to use when downloading the File. Default=&quot;csv&quot;</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$dbname</span><span class="var-description">: Name of the Database to use</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$user</span><span class="var-description">: User to Access the Database</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$password</span><span class="var-description">: Password to Access the Database</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$host</span><span class="var-description">: Name of the Host holding the DB</span>			</li>
				</ul>
		
		
	</div>
<a name="method_db_connect" id="_db_connect"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<span class="method-title">_db_connect</span> (line <span class="line-number"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a206">206</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Generates a CSV File from an SQL String (and outputs it to the browser)</p>
	<ul class="tags">
				<li><span class="field">access:</span> private</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			_db_connect
		</span>
					([<span class="var-type">String</span>&nbsp;<span class="var-name">$dbname</span> = <span class="var-default">"mysql"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$user</span> = <span class="var-default">"root"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$password</span> = <span class="var-default">""</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$host</span> = <span class="var-default">"localhost"</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$dbname</span><span class="var-description">: Name of the Database</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$user</span><span class="var-description">: User to Access the Database</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$password</span><span class="var-description">: Password to Access the Database</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$host</span><span class="var-description">: Name of the Host holding the DB</span>			</li>
				</ul>
		
		
	</div>
<a name="method_define_newline" id="_define_newline"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<span class="method-title">_define_newline</span> (line <span class="line-number"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a126">126</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Define EOL character according to target OS</p>
	<ul class="tags">
				<li><span class="field">return:</span> A String containing the End Of Line Sequence corresponding to the client's OS</li>
				<li><span class="field">access:</span> private</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">String</span>
		<span class="method-name">
			_define_newline
		</span>
				()
			</div>
	
		
		
	</div>
<a name="method_generate_csv" id="_generate_csv"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<span class="method-title">_generate_csv</span> (line <span class="line-number"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a230">230</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Generates a CSV File from an SQL String (and outputs it to the browser)</p>
	<ul class="tags">
				<li><span class="field">access:</span> private</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			_generate_csv
		</span>
					(<span class="var-type">String</span>&nbsp;<span class="var-name">$query_string</span>, [<span class="var-type">String</span>&nbsp;<span class="var-name">$dbname</span> = <span class="var-default">"mysql"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$user</span> = <span class="var-default">"root"</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$password</span> = <span class="var-default">""</span>], [<span class="var-type">String</span>&nbsp;<span class="var-name">$host</span> = <span class="var-default">"localhost"</span>])
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$query_string</span><span class="var-description">: An SQL statement (usually a SELECT statement)</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$dbname</span><span class="var-description">: Name of the Database</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$user</span><span class="var-description">: User to Access the Database</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$password</span><span class="var-description">: Password to Access the Database</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$host</span><span class="var-description">: Name of the Host holding the DB</span>			</li>
				</ul>
		
		
	</div>
<a name="method_get_browser_type" id="_get_browser_type"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<span class="method-title">_get_browser_type</span> (line <span class="line-number"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a151">151</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Define the client's browser type</p>
	<ul class="tags">
				<li><span class="field">return:</span> A String containing the Browser's type or brand</li>
				<li><span class="field">access:</span> private</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">String</span>
		<span class="method-name">
			_get_browser_type
		</span>
				()
			</div>
	
		
		
	</div>
<a name="method_get_mime_type" id="_get_mime_type"><!-- --></a>
<div class="evenrow">
	
	<div class="method-header">
		<span class="method-title">_get_mime_type</span> (line <span class="line-number"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a188">188</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Define MIME-TYPE according to target Browser</p>
	<ul class="tags">
				<li><span class="field">return:</span> A string containing the MIME-TYPE String corresponding to the client's browser</li>
				<li><span class="field">access:</span> private</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">String</span>
		<span class="method-name">
			_get_mime_type
		</span>
				()
			</div>
	
		
		
	</div>
<a name="method_valToCsvHelper" id="_valToCsvHelper"><!-- --></a>
<div class="oddrow">
	
	<div class="method-header">
		<span class="method-title">_valToCsvHelper</span> (line <span class="line-number"><a href="..//__filesource/fsource_iam_csvdump__iam_csvdump.php.html#a96">96</a></span>)
	</div> 
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Works on a string to include in a csv string.</p>
	<ul class="tags">
				<li><span class="field">see:</span> <a href="../iam_csvdump/iam_csvdump.html#methodarrayToCsvString">iam_csvdump::arrayToCsvString()</a></li>
				<li><span class="field">access:</span> private</li>
			</ul>
	
	<div class="method-signature">
		<span class="method-result">String</span>
		<span class="method-name">
			_valToCsvHelper
		</span>
					(<span class="var-type">String</span>&nbsp;<span class="var-name">$val</span>, <span class="var-type">String</span>&nbsp;<span class="var-name">$separator</span>, <span class="var-type">Mixed</span>&nbsp;<span class="var-name">$trimFunction</span>)
			</div>
	
			<ul class="parameters">
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$val</span>			</li>
					<li>
				<span class="var-type">String</span>
				<span class="var-name">$separator</span>			</li>
					<li>
				<span class="var-type">Mixed</span>
				<span class="var-name">$trimFunction</span><span class="var-description">: 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.</span>			</li>
				</ul>
		
		
	</div>
						
		</div>
	</div>
	
	<p class="notes" id="credit">
		Documentation generated on Fri, 12 Dec 2003 18:43:03 -0300 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.2.3</a>
	</p>
	</div></body>
</html>
Return current item: IAM CSV Dump