admin | e177033 | 2006-09-27 00:30:58 +0000 | [diff] [blame] | 1 | <!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 |
|
| 10 | <script type="text/javascript" src="../scripts/nav.js"></script>
|
| 11 | <script type="text/javascript" src="../scripts/prototype.lite.js"></script>
|
| 12 | <script type="text/javascript" src="../scripts/moo.fx.js"></script>
|
| 13 | <script type="text/javascript">
|
| 14 | window.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> ›
|
| 49 | <a href="../index.html">User Guide Home</a> ›
|
| 50 | <a href="index.html">Database Library</a> ›
|
| 51 | Database 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 <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <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> This class must be initialized independently since it is a separate class from the main Database class.
|
| 70 | More 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.
|
| 90 | Example:</p>
|
| 91 |
|
| 92 | <code>
|
| 93 | $this->load->dbexport();<br />
|
| 94 | <br />
|
| 95 | $query = $this->db->query("SELECT * FROM mytable");<br />
|
| 96 | <br />
|
| 97 | echo $this->dbexport->cvs_from_result($query);
|
| 98 | </code>
|
| 99 |
|
| 100 | <p>The second and third parameters allows you to
|
| 101 | set 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 />
|
| 107 | echo $this->dbexport->cvs_from_result($query, $delimiter, $newline);
|
| 108 | </code>
|
| 109 |
|
| 110 | <p class="important"><strong>Important:</strong> This function will NOT write the CVS file for you. It simply creates the CVS layout.
|
| 111 | If 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
|
| 118 | may 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 | 'root' => 'root',<br />
|
| 127 | 'element' => 'element', <br />
|
| 128 | 'newline' => "\n", <br />
|
| 129 | ';tab' => "\t"<br />
|
| 130 | );<br />
|
| 131 | <br />
|
| 132 | echo $this->dbexport->cvs_from_result($query, $config);
|
| 133 | </code>
|
| 134 |
|
| 135 | <p class="important"><strong>Important:</strong> This function will NOT write the CVS file for you. It simply creates the CVS layout.
|
| 136 | If 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>
|
| 148 | Previous Topic: <a href="utilities.html">Database Utility Class</a>
|
| 149 | ·
|
| 150 | <a href="#top">Top of Page</a> ·
|
| 151 | <a href="../index.html">User Guide Home</a> ·
|
| 152 | Next Topic: <a href="../libraries/email.html">Email Class</a>
|
| 153 | <p>
|
| 154 | <p><a href="http://www.codeigniter.com">Code Igniter</a> · Copyright © 2006 · <a href="http://www.pmachine.com">pMachine, Inc.</a></p>
|
| 155 | </div>
|
| 156 |
|
| 157 | </body>
|
| 158 | </html> |