admin | 3b60ae4 | 2006-09-25 23:26:03 +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 |
|
Derek Allard | 404e35d | 2007-08-07 01:00:45 +0000 | [diff] [blame] | 5 | <title>CodeIgniter User Guide : Database Utility Class</title>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 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 |
|
admin | 17a890d | 2006-09-27 20:42:42 +0000 | [diff] [blame] | 10 | <script type="text/javascript" src="../nav/nav.js"></script>
|
admin | 2296fc3 | 2006-09-27 21:07:02 +0000 | [diff] [blame] | 11 | <script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
admin | 17a890d | 2006-09-27 20:42:42 +0000 | [diff] [blame] | 12 | <script type="text/javascript" src="../nav/moo.fx.js"></script>
|
Derek Allard | b341237 | 2007-10-25 12:15:16 +0000 | [diff] [blame] | 13 | <script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 14 |
|
| 15 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
| 16 | <meta http-equiv='expires' content='-1' />
|
| 17 | <meta http-equiv= 'pragma' content='no-cache' />
|
| 18 | <meta name='robots' content='all' />
|
| 19 | <meta name='author' content='Rick Ellis' />
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 20 | <meta name='description' content='CodeIgniter User Guide' />
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 21 |
|
| 22 | </head>
|
| 23 | <body>
|
| 24 |
|
| 25 | <!-- START NAVIGATION -->
|
| 26 | <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
| 27 | <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>
|
| 28 | <div id="masthead">
|
| 29 | <table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
| 30 | <tr>
|
Derek Allard | 60ca9b7 | 2007-07-12 19:53:27 +0000 | [diff] [blame] | 31 | <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
|
admin | c0d5d52 | 2006-10-30 19:40:35 +0000 | [diff] [blame] | 32 | <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 33 | </tr>
|
| 34 | </table>
|
| 35 | </div>
|
| 36 | <!-- END NAVIGATION -->
|
| 37 |
|
| 38 |
|
| 39 | <!-- START BREADCRUMB -->
|
| 40 | <table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
| 41 | <tr>
|
| 42 | <td id="breadcrumb">
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 43 | <a href="http://www.codeigniter.com/">CodeIgniter Home</a> ›
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 44 | <a href="../index.html">User Guide Home</a> ›
|
| 45 | <a href="index.html">Database Library</a> ›
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 46 | Database Utility Class
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 47 | </td>
|
Derek Allard | bc03091 | 2007-06-24 18:25:29 +0000 | [diff] [blame] | 48 | <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 49 | </tr>
|
| 50 | </table>
|
| 51 | <!-- END BREADCRUMB -->
|
| 52 |
|
| 53 |
|
| 54 | <br clear="all" />
|
| 55 |
|
| 56 |
|
| 57 | <!-- START CONTENT -->
|
| 58 | <div id="content">
|
| 59 |
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 60 | <h1>Database Utility Class</h1>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 61 |
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 62 | <p>The Database Utility Class contains functions that help you manage your database.</p>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 63 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 64 | <h3>Table of Contents</h3>
|
| 65 |
|
| 66 | <ul>
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 67 | <li><a href="#init">Initializing the Utility Class</a></li>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 68 | <li><a href="#create">Creating a Database</a></li>
|
| 69 | <li><a href="#drop">Dropping a Database</a></li>
|
| 70 | <li><a href="#list">Listing your Databases</a></li>
|
| 71 | <li><a href="#opttb">Optimizing your Tables</a></li>
|
| 72 | <li><a href="#repair">Repairing your Databases</a></li>
|
| 73 | <li><a href="#optdb">Optimizing your Database</a></li>
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 74 | <li><a href="#csv">CSV Files from a Database Result</a></li>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 75 | <li><a href="#xml">XML Files from a Database Result</a></li>
|
| 76 | <li><a href="#backup">Backing up your Database</a></li>
|
| 77 | </ul>
|
| 78 |
|
| 79 |
|
| 80 | <a name="init"></a>
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 81 | <h2>Initializing the Utility Class</h2>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 82 |
|
admin | fd2750b | 2006-10-06 17:29:12 +0000 | [diff] [blame] | 83 | <p class="important"><strong>Important:</strong> In order to initialize the Utility class, your database driver must
|
admin | 572ed81 | 2006-10-12 18:01:52 +0000 | [diff] [blame] | 84 | already be running, since the utilities class relies on it.</p>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 85 |
|
admin | fd2750b | 2006-10-06 17:29:12 +0000 | [diff] [blame] | 86 | <p>Load the Utility Class as follows:</p>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 87 |
|
admin | 572ed81 | 2006-10-12 18:01:52 +0000 | [diff] [blame] | 88 | <code>$this->load->dbutil()</code>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 89 |
|
| 90 | <p>Once initialized you will access the functions using the <dfn>$this->dbutil</dfn> object:</p>
|
| 91 |
|
| 92 | <code>$this->dbutil->some_function()</code>
|
| 93 |
|
| 94 |
|
| 95 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 96 | <a name="create"></a>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 97 | <h2>$this->dbutil->create_database('db_name')</h2>
|
| 98 |
|
admin | 985a638 | 2006-10-28 18:47:16 +0000 | [diff] [blame] | 99 | <p>Permits you to create the database specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 100 |
|
| 101 | <code>if ($this->dbutil->create_database('my_db'))<br />
|
| 102 | {<br />
|
| 103 | echo 'Database created!';<br />
|
| 104 | }</code>
|
| 105 |
|
| 106 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 107 |
|
| 108 | <a name="drop"></a>
|
admin | 985a638 | 2006-10-28 18:47:16 +0000 | [diff] [blame] | 109 | <h2>$this->dbutil->drop_database('db_name')</h2>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 110 |
|
admin | 985a638 | 2006-10-28 18:47:16 +0000 | [diff] [blame] | 111 | <p>Permits you to drop the database specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 112 |
|
| 113 | <code>if ($this->dbutil->drop_database('my_db'))<br />
|
| 114 | {<br />
|
| 115 | echo 'Database deleted!';<br />
|
| 116 | }</code>
|
| 117 |
|
| 118 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 119 | <a name="list"></a>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 120 | <h2>$this->dbutil->list_databases()</h2>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 121 | <p>Returns an array of database names:</p>
|
| 122 |
|
| 123 |
|
| 124 | <code>
|
| 125 | $dbs = $this->dbutil->list_databases();<br />
|
| 126 | <br />
|
| 127 | foreach($dbs as $db)<br />
|
| 128 | {<br />
|
| 129 | echo $db;<br />
|
| 130 | }</code>
|
| 131 |
|
| 132 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 133 | <a name="opttb"></a>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 134 | <h2>$this->dbutil->optimize_table('table_name');</h2>
|
| 135 |
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 136 | <p class="important"><strong>Note:</strong> This features is only available for MySQL/MySQLi databases.</p>
|
| 137 |
|
| 138 |
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 139 | <p>Permits you to optimize a table using the table name specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
|
| 140 |
|
| 141 | <code>
|
| 142 | if ($this->dbutil->optimize_table('table_name'))<br />
|
| 143 | {<br />
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 144 | echo 'Success!';<br />
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 145 | }
|
| 146 | </code>
|
| 147 |
|
| 148 | <p><strong>Note:</strong> Not all database platforms support table optimization.</p>
|
| 149 |
|
| 150 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 151 | <a name="repair"></a>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 152 | <h2>$this->dbutil->repair_table('table_name');</h2>
|
| 153 |
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 154 | <p class="important"><strong>Note:</strong> This features is only available for MySQL/MySQLi databases.</p>
|
| 155 |
|
| 156 |
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 157 | <p>Permits you to repair a table using the table name specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
|
| 158 |
|
| 159 | <code>
|
admin | 985a638 | 2006-10-28 18:47:16 +0000 | [diff] [blame] | 160 | if ($this->dbutil->repair_table('table_name'))<br />
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 161 | {<br />
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 162 | echo 'Success!';<br />
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 163 | }
|
| 164 | </code>
|
| 165 |
|
| 166 | <p><strong>Note:</strong> Not all database platforms support table repairs.</p>
|
| 167 |
|
| 168 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 169 | <a name="optdb"></a>
|
admin | e5bb936 | 2006-09-27 00:31:22 +0000 | [diff] [blame] | 170 | <h2>$this->dbutil->optimize_database();</h2>
|
| 171 |
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 172 | <p class="important"><strong>Note:</strong> This features is only available for MySQL/MySQLi databases.</p>
|
| 173 |
|
admin | 985a638 | 2006-10-28 18:47:16 +0000 | [diff] [blame] | 174 | <p>Permits you to optimize the database your DB class is currently connected to. Returns an array containing the DB status messages or FALSE on failure.</p>
|
admin | e5bb936 | 2006-09-27 00:31:22 +0000 | [diff] [blame] | 175 |
|
| 176 | <code>
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 177 | $result = $this->dbutil->optimize_database();<br />
|
admin | e5bb936 | 2006-09-27 00:31:22 +0000 | [diff] [blame] | 178 | <br />
|
| 179 | if ($result !== FALSE)<br />
|
| 180 | {<br />
|
| 181 | print_r($result);<br />
|
| 182 | }
|
| 183 | </code>
|
| 184 |
|
| 185 | <p><strong>Note:</strong> Not all database platforms support table optimization.</p>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 186 |
|
| 187 |
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 188 | <a name="csv"></a>
|
| 189 | <h2>$this->dbutil->csv_from_result($db_result)</h2>
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 190 |
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 191 | <p>Permits you to generate a CSV file from a query result. The first parameter of the function must contain the result object from your query.
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 192 | Example:</p>
|
| 193 |
|
| 194 | <code>
|
| 195 | $this->load->dbutil();<br />
|
| 196 | <br />
|
| 197 | $query = $this->db->query("SELECT * FROM mytable");<br />
|
| 198 | <br />
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 199 | echo $this->dbutil->csv_from_result($query);
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 200 | </code>
|
| 201 |
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 202 | <p>The second and third parameters allows you to
|
Derek Allard | c644128 | 2007-07-04 23:54:32 +0000 | [diff] [blame] | 203 | set the delimiter and newline character. By default tabs are used as the delimiter and "\n" is used as a new line. Example:</p>
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 204 |
|
| 205 | <code>
|
| 206 | $delimiter = ",";<br />
|
| 207 | $newline = "\r\n";<br />
|
| 208 | <br />
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 209 | echo $this->dbutil->csv_from_result($query, $delimiter, $newline);
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 210 | </code>
|
| 211 |
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 212 | <p><strong>Important:</strong> This function will NOT write the CSV file for you. It simply creates the CSV layout.
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 213 | If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p>
|
| 214 |
|
| 215 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 216 | <a name="xml"></a>
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 217 | <h2>$this->dbutil->xml_from_result($db_result)</h2>
|
| 218 |
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 219 | <p>Permits you to generate an XML file from a query result. The first parameter expects a query result object, the second
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 220 | may contain an optional array of config parameters. Example:</p>
|
| 221 |
|
| 222 | <code>
|
| 223 | $this->load->dbutil();<br />
|
| 224 | <br />
|
| 225 | $query = $this->db->query("SELECT * FROM mytable");<br />
|
| 226 | <br />
|
| 227 | $config = array (<br />
|
| 228 | 'root' => 'root',<br />
|
| 229 | 'element' => 'element', <br />
|
| 230 | 'newline' => "\n", <br />
|
admin | c5f7fa3 | 2006-10-06 02:10:23 +0000 | [diff] [blame] | 231 | 'tab' => "\t"<br />
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 232 | );<br />
|
| 233 | <br />
|
admin | 24dd7e7 | 2006-10-01 19:02:29 +0000 | [diff] [blame] | 234 | echo $this->dbutil->xml_from_result($query, $config);
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 235 | </code>
|
| 236 |
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 237 | <p><strong>Important:</strong> This function will NOT write the XML file for you. It simply creates the XML layout.
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 238 | If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p>
|
| 239 |
|
| 240 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 241 | <a name="backup"></a>
|
| 242 | <h2>$this->dbutil->backup()</h2>
|
admin | 3dd978f | 2006-09-30 19:24:45 +0000 | [diff] [blame] | 243 |
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 244 | <p>Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format.</p>
|
admin | 0e42554 | 2006-10-01 03:37:43 +0000 | [diff] [blame] | 245 |
|
admin | f66de86 | 2006-10-10 23:30:04 +0000 | [diff] [blame] | 246 | <p class="important"><strong>Note:</strong> This features is only available for MySQL/MySQLi databases.</p>
|
| 247 |
|
admin | 0e42554 | 2006-10-01 03:37:43 +0000 | [diff] [blame] | 248 | <p>Note: Due to the limited execution time and memory available to PHP, backing up very large
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 249 | databases may not be possible. If your database is very large you might need to backup directly from your SQL server
|
admin | 0e42554 | 2006-10-01 03:37:43 +0000 | [diff] [blame] | 250 | via the command line, or have your server admin do it for you if you do not have root privileges.</p>
|
| 251 |
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 252 | <h3>Usage Example</h3>
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 253 |
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 254 | <code>
|
| 255 | <dfn>// Load the DB utility class</dfn><br />
|
| 256 | $this->load->dbutil();<br /><br />
|
| 257 |
|
admin | c5f7fa3 | 2006-10-06 02:10:23 +0000 | [diff] [blame] | 258 | <dfn>// Backup your entire database and assign it to a variable</dfn><br />
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 259 | $backup =& $this->dbutil->backup();
|
| 260 |
|
| 261 | <br /><br />
|
| 262 | <dfn>// Load the file helper and write the file to your server</dfn><br />
|
| 263 | $this->load->helper('file');<br />
|
| 264 | write_file('/path/to/mybackup.gz', $backup);
|
| 265 |
|
| 266 | <br /><br />
|
| 267 | <dfn>// Load the download helper and send the file to your desktop</dfn><br />
|
| 268 | $this->load->helper('download');<br />
|
| 269 | force_download('mybackup.gz', $backup);
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 270 | </code>
|
admin | 3ed8c51 | 2006-09-29 23:26:28 +0000 | [diff] [blame] | 271 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 272 | <h3>Setting Backup Preferences</h3>
|
| 273 |
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 274 | <p>Backup preferences are set by submitting an array of values to the first parameter of the backup function. Example:</p>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 275 |
|
| 276 | <code>$prefs = array(<br />
|
| 277 | 'tables' => array('table1', 'table2'), // Array of tables to backup.<br />
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 278 | 'ignore' => array(), // List of tables to omit from the backup<br />
|
| 279 | 'format' => 'txt', // gzip, zip, txt<br />
|
| 280 | 'filename' => 'mybackup.sql', // File name - NEEDED ONLY WITH ZIP FILES<br />
|
| 281 | 'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file<br />
|
| 282 | 'add_insert' => TRUE, // Whether to add INSERT data to backup file<br />
|
| 283 | 'newline' => "\n" // Newline character used in backup file<br />
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 284 | );<br />
|
| 285 | <br />
|
| 286 | $this->dbutil->backup($prefs);
|
| 287 | </code>
|
| 288 |
|
admin | 0e42554 | 2006-10-01 03:37:43 +0000 | [diff] [blame] | 289 |
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 290 | <h3>Description of Backup Preferences</h3>
|
| 291 |
|
| 292 | <table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
|
| 293 | <tr>
|
| 294 | <th>Preference</th>
|
| 295 | <th>Default Value</th>
|
| 296 | <th>Options</th>
|
| 297 | <th>Description</th>
|
| 298 | </tr><tr>
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 299 | <td class="td"><strong>tables</strong></td><td class="td">empty array</td><td class="td">None</td><td class="td">An array of tables you want backed up. If left blank all tables will be exported.</td>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 300 | </tr><tr>
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 301 | <td class="td"><strong>ignore</strong></td><td class="td">empty array</td><td class="td">None</td><td class="td">An array of tables you want the backup routine to ignore.</td>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 302 | </tr><tr>
|
| 303 | <td class="td"><strong>format</strong></td><td class="td">gzip</td><td class="td">gzip, zip, txt</td><td class="td">The file format of the export file.</td>
|
| 304 | </tr><tr>
|
admin | e856ff4 | 2006-10-02 02:38:30 +0000 | [diff] [blame] | 305 | <td class="td"><strong>filename</strong></td><td class="td">the current date/time</td><td class="td">None</td><td class="td">The name of the backed-up file. The name is needed only if you are using zip compression.</td>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 306 | </tr><tr>
|
| 307 | <td class="td"><strong>add_drop</strong></td><td class="td">TRUE</td><td class="td">TRUE/FALSE</td><td class="td">Whether to include DROP TABLE statements in your SQL export file.</td>
|
| 308 | </tr><tr>
|
admin | 4003718 | 2006-10-11 19:16:58 +0000 | [diff] [blame] | 309 | <td class="td"><strong>add_insert</strong></td><td class="td">TRUE</td><td class="td">TRUE/FALSE</td><td class="td">Whether to include INSERT statements in your SQL export file.</td>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 310 | </tr><tr>
|
admin | 4003718 | 2006-10-11 19:16:58 +0000 | [diff] [blame] | 311 | <td class="td"><strong>newline</strong></td><td class="td">"\n"</td><td class="td">"\n", "\r", "\r\n"</td><td class="td">Type of newline to use in your SQL export file.</td>
|
admin | 32cb0e5 | 2006-09-30 20:36:59 +0000 | [diff] [blame] | 312 |
|
| 313 | </tr>
|
| 314 | </table>
|
| 315 |
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 316 |
|
| 317 | </div>
|
| 318 | <!-- END CONTENT -->
|
| 319 |
|
| 320 |
|
| 321 | <div id="footer">
|
| 322 | <p>
|
Rick Ellis | 325197e | 2006-11-20 17:29:05 +0000 | [diff] [blame] | 323 | Previous Topic: <a href="caching.html">DB Caching Class</a>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 324 | ·
|
| 325 | <a href="#top">Top of Page</a> ·
|
| 326 | <a href="../index.html">User Guide Home</a> ·
|
Derek Allard | 9da4dbc | 2007-04-03 11:39:35 +0000 | [diff] [blame] | 327 | Next Topic: <a href="../libraries/email.html"> Email Class</a>
|
Derek Allard | c644128 | 2007-07-04 23:54:32 +0000 | [diff] [blame] | 328 | </p>
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 329 | <p><a href="http://www.codeigniter.com">CodeIgniter</a> · Copyright © 2007 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
admin | 3b60ae4 | 2006-09-25 23:26:03 +0000 | [diff] [blame] | 330 | </div>
|
| 331 |
|
| 332 | </body>
|
| 333 | </html> |