blob: 6932fbcb8c82b71de6f633dcbfe01e3160727127 [file] [log] [blame]
admine1770332006-09-27 00:30:58 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html>
3<head>
4
5<title>Code Igniter User Guide</title>
6
7<style type='text/css' media='all'>@import url('../userguide.css');</style>
8<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
9
admin17a890d2006-09-27 20:42:42 +000010<script type="text/javascript" src="../nav/nav.js"></script>
admin2296fc32006-09-27 21:07:02 +000011<script type="text/javascript" src="../nav/prototype.lite.js"></script>
admin17a890d2006-09-27 20:42:42 +000012<script type="text/javascript" src="../nav/moo.fx.js"></script>
admine1770332006-09-27 00:30:58 +000013<script type="text/javascript">
14window.onload = function() {
15 myHeight = new fx.Height('nav', {duration: 400});
16 myHeight.hide();
17}
18</script>
19
20<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
21<meta http-equiv='expires' content='-1' />
22<meta http-equiv= 'pragma' content='no-cache' />
23<meta name='robots' content='all' />
24<meta name='author' content='Rick Ellis' />
25<meta name='description' content='Code Igniter User Guide' />
26
27</head>
28<body>
29
30<!-- START NAVIGATION -->
31<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
32<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
33<div id="masthead">
34<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
35<tr>
36<td><h1>Code Igniter User Guide Version 1.5.0</h1></td>
37<td id="breadcrumb_right"><a href="../toc.html">Full Table of Contents</a></td>
38</tr>
39</table>
40</div>
41<!-- END NAVIGATION -->
42
43
44<!-- START BREADCRUMB -->
45<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
46<tr>
47<td id="breadcrumb">
48<a href="http://www.codeigniter.com/">Code Igniter Home</a> &nbsp;&#8250;&nbsp;
49<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
50<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
51Database Export Class
52</td>
53<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="www.codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
54</tr>
55</table>
56<!-- END BREADCRUMB -->
57
58
59<br clear="all" />
60
61
62<!-- START CONTENT -->
63<div id="content">
64
65<h1>Database Export Class</h1>
66
67<p>The Database Utilities Class contains functions that help you export your data.</p>
68
69<p class="important"><strong>Important:</strong>&nbsp; This class must be initialized independently since it is a separate class from the main Database class.
70More info below...</p>
71
72
73<h2>Initializing the Export Class</h2>
74
75<p>To initialize this class please use the following code:</p>
76
77<code>$this->load->dbexport()</code>
78
79<p>You can also autoload this class from within your <dfn>config/autoload.php</dfn> file by specifying <kbd>dbexport</kbd> in the <samp>$autoload['libraries']</samp> array.</p>
80
81<p>Once initialized you will access the functions using the <dfn>$this->dbexport</dfn> object:</p>
82
83<code>$this->dbexport->some_function()</code>
84
85
86
87<h2>$this->dbexport->cvs_from_result($db_result)</h2>
88
89<p>Permits you to generate a CVS file from a query result. The first parameter of the function must contain the result object from your query.
90Example:</p>
91
92<code>
93$this->load->dbexport();<br />
94<br />
95$query = $this->db->query("SELECT * FROM mytable");<br />
96<br />
97echo $this->dbexport->cvs_from_result($query);
98</code>
99
100<p>The second and third parameters allows you to
101set the delimiter and newline character. By default tabs are used as the delimiter and "\n" is used as a new line. Example:
102
103<code>
104$delimiter = ",";<br />
105$newline = "\r\n";<br />
106<br />
107echo $this->dbexport->cvs_from_result($query, $delimiter, $newline);
108</code>
109
110<p class="important"><strong>Important:</strong>&nbsp; This function will NOT write the CVS file for you. It simply creates the CVS layout.
111If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p>
112
113
114
115<h2>$this->dbexport->xml_from_result($db_result)</h2>
116
117<p>Permits you to generate an XML file from a query result. The first parameter expects a query result object, the second
118may contain an optional array of config parameters. Example:</p>
119
120<code>
121$this->load->dbexport();<br />
122<br />
123$query = $this->db->query("SELECT * FROM mytable");<br />
124<br />
125$config = array (<br />
126&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'root'&nbsp;&nbsp;&nbsp; => 'root',<br />
127&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'element' => 'element', <br />
128&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'newline' => "\n", <br />
129&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';tab'&nbsp;&nbsp;&nbsp;&nbsp;=> "\t"<br />
130&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
131<br />
132echo $this->dbexport->cvs_from_result($query, $config);
133</code>
134
135<p class="important"><strong>Important:</strong>&nbsp; This function will NOT write the CVS file for you. It simply creates the CVS layout.
136If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p>
137
138
139
140
141
142</div>
143<!-- END CONTENT -->
144
145
146<div id="footer">
147<p>
148Previous Topic:&nbsp;&nbsp;<a href="utilities.html">Database Utility Class</a>
149&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
150<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
151<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
152Next Topic:&nbsp;&nbsp;<a href="../libraries/email.html">Email Class</a>
153<p>
154<p><a href="http://www.codeigniter.com">Code Igniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006 &nbsp;&middot;&nbsp; <a href="http://www.pmachine.com">pMachine, Inc.</a></p>
155</div>
156
157</body>
158</html>