From 32cb0e53301575b57c14760ea01649719a435c5e Mon Sep 17 00:00:00 2001
From: admin The Database Utilities Class contains functions that help you manage your database. Important: This class must be initialized independently since it is a separate class from the main Database class.
More info below... To initialize this class please use the following code:Table of Contents
+
+
+
+
+
+
+Initializing the Utilities Class
+
Initializing the Utilities Class
-
$this->load->dbutil()
@@ -84,6 +100,7 @@ More info below...
Permits you to create a database using the name specified in the first parameter. Returns TRUE/FALSE based on success or failure:
@@ -94,6 +111,8 @@ More info below... } + +Permits you to drop a database using the table name specified in the first parameter. Returns TRUE/FALSE based on success or failure:
@@ -104,8 +123,8 @@ More info below... } +Returns an array of database names:
@@ -118,7 +137,7 @@ foreach($dbs as $db)Permits you to optimize a table using the table name specified in the first parameter. Returns TRUE/FALSE based on success or failure:
@@ -133,6 +152,7 @@ if ($this->dbutil->optimize_table('table_name'))Note: Not all database platforms support table optimization.
+Permits you to repair a table using the table name specified in the first parameter. Returns TRUE/FALSE based on success or failure:
@@ -147,13 +167,13 @@ if ($this->dbutil->optimize_table('table_name'))Note: Not all database platforms support table repairs.
- +Permits you to optimize the database your DB class is currently connected to. Returns an array containing the returned status messages or FALSE on failure.
-$result = $this->dbutil->optimize_databas();
+$result = $this->dbutil->optimize_databass();
if ($result !== FALSE)
{
@@ -164,7 +184,7 @@ if ($result !== FALSE)
Note: Not all database platforms support table optimization.
-
+
$this->dbutil->cvs_from_result($db_result)
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.
@@ -192,7 +212,7 @@ echo $this->dbutil->cvs_from_result($query, $delimiter, $newline);
If you need to write the file use the File Helper.
-
+
$this->dbutil->xml_from_result($db_result)
Permits you to generate an XML file from a query result. The first parameter expects a query result object, the second
@@ -217,12 +237,70 @@ echo $this->dbutil->cvs_from_result($query, $config);
If you need to write the file use the File Helper.
-$this->dbutil->export()
+
+$this->dbutil->backup()
-Permits you to export your database or any desired tables. Export data can be downloaded to your desktop, archived to your
-server, or simply displayed. Archived files can be compressed.
+
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. Example:
+$this->dbutil->backup();
+// When no parameters are passed the full database is backed up and downloaded to your desktop as a Gzip file.
+
+
+Setting Backup Preferences
+
+Preferences are set by submitting an array of values to the first parameter of the backup function. Example:
+
+$prefs = array(
+ 'tables' => array('table1', 'table2'), // Array of tables to backup.
+ 'ignore' => array(), // List of tables to omit from the backup
+ 'format' => 'txt', // gzip, zip, txt
+ 'action' => 'archive', // download, archive, echo, return
+ 'filename' => 'sql_archive', // File name - no file extension!
+ 'filepath' => '/path/to/folder/', // Path needed only when archiving to your server
+ 'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file
+ 'add_insert' => TRUE, // Whether to add INSERT data to backup file
+ 'newline' => "\n" // Newline character used in backup file
+ );
+
+$this->dbutil->backup($prefs);
+
+
+Description of Backup Preferences
+
+
+
+Preference
+Default Value
+Options
+Description
+
+tables empty array None An array of tables you would liked backed up. If left blank all tables will be exported.
+
+ignore empty array None An array of tables you would liked the backup routine to ignore.
+
+format gzip gzip, zip, txt The file format of the export file.
+
+action download download, archive, echo, return 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.
+
+filename the current date/time None The name of the export file. DO NOT include the file extension.
+
+filepath empty string None The path to the directory where you would like the archived file written to. Used ONLY when the "archive" action is set.
+
+add_drop TRUE TRUE/FALSE Whether to include DROP TABLE statements in your SQL export file.
+
+add_insert/strong> TRUE TRUE/FALSE Whether to include INSERT statements in your SQL export file.
+
+newline/strong> "\n" "\n", "\r", "\r\n" Type of newline to use in your SQL export file.
+
+
+
+VERY IMPORTANT: If you are using the download action to send the file to your desktop,
+DO NOT display any data in the controller in which you are triggering the backup. Since Code Igniter buffers all output, any data
+sent to the browser will be included in your export file. This issue ONLY applies to downloads. If you are using any other action
+you can display data in your controller.
--
cgit v1.2.3-24-g4f1b