diff options
Diffstat (limited to 'user_guide/database/utilities.html')
-rw-r--r-- | user_guide/database/utilities.html | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html index cbd8be784..cf42aaee5 100644 --- a/user_guide/database/utilities.html +++ b/user_guide/database/utilities.html @@ -240,34 +240,44 @@ If you need to write the file use the <a href="../helpers/file_helper.html">File <a name="backup"></a>
<h2>$this->dbutil->backup()</h2>
-<p>Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format,
-and it can be downloaded to your desktop, archived to your
-server, returned as a string, or simply displayed.</p>
+<p>Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format.</p>
<p>Note: Due to the limited execution time and memory available to PHP, backing up very large
databases may not be possible. If your database is very large you might need to backup directly from your SQL server
via the command line, or have your server admin do it for you if you do not have root privileges.</p>
-<p>Usage example:</p>
+<h3>Usage Example</h3>
-<code>$this->dbutil->backup();<br /><br />
-// When no parameters are passed the full database is backed up and downloaded to your desktop as a Gzip file.
+<code>
+<dfn>// Load the DB utility class</dfn><br />
+$this->load->dbutil();<br /><br />
+
+<dfn>// Backup your entire database</dfn><br />
+$backup =& $this->dbutil->backup();
+
+<br /><br />
+<dfn>// Load the file helper and write the file to your server</dfn><br />
+$this->load->helper('file');<br />
+write_file('/path/to/mybackup.gz', $backup);
+
+<br /><br />
+<dfn>// Load the download helper and send the file to your desktop</dfn><br />
+$this->load->helper('download');<br />
+force_download('mybackup.gz', $backup);
</code>
<h3>Setting Backup Preferences</h3>
-<p>Preferences are set by submitting an array of values to the first parameter of the backup function. Example:</p>
+<p>Backup preferences are set by submitting an array of values to the first parameter of the backup function. Example:</p>
<code>$prefs = array(<br />
'tables' => array('table1', 'table2'), // Array of tables to backup.<br />
- 'ignore' => array(), // List of tables to omit from the backup<br />
- 'format' => 'txt', // gzip, zip, txt<br />
- 'action' => 'archive', // download, archive, echo, return<br />
- 'filename' => 'sql_archive', // File name - no file extension!<br />
- 'filepath' => '/path/to/folder/', // Path needed only when archiving to your server<br />
- 'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file<br />
- 'add_insert' => TRUE, // Whether to add INSERT data to backup file<br />
- 'newline' => "\n" // Newline character used in backup file<br />
+ 'ignore' => array(), // List of tables to omit from the backup<br />
+ 'format' => 'txt', // gzip, zip, txt<br />
+ 'filename' => 'mybackup.sql', // File name - NEEDED ONLY WITH ZIP FILES<br />
+ 'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file<br />
+ 'add_insert' => TRUE, // Whether to add INSERT data to backup file<br />
+ 'newline' => "\n" // Newline character used in backup file<br />
);<br />
<br />
$this->dbutil->backup($prefs);
@@ -283,17 +293,13 @@ $this->dbutil->backup($prefs); <th>Options</th>
<th>Description</th>
</tr><tr>
-<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 would liked backed up. If left blank all tables will be exported.</td>
+<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>
</tr><tr>
-<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 would liked the backup routine to ignore.</td>
+<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>
</tr><tr>
<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>
</tr><tr>
-<td class="td"><strong>action</strong></td><td class="td">download</td><td class="td">download, archive, echo, return</td><td class="td">What action you would like applied to the data. "download" sends it to your desktop, "archive" writes the file to your server, "return" returns the backup as a string, and "echo" simply echos it out for viewing.</td>
-</tr><tr>
-<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 export file. DO NOT include the file extension.</td>
-</tr><tr>
-<td class="td"><strong>filepath</strong></td><td class="td">empty string</td><td class="td">None</td><td class="td">The path to the directory where you would like the archived file written to. Used ONLY when the "archive" action is set.</td>
+<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>
</tr><tr>
<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>
</tr><tr>
|