[eluser]Unknown[/eluser]
function backup()
{
$con=mysql_connect("localhost","root","impound");
$this->input->get_post('newimpound', TRUE);
if (!$con)
{
die('Could not connect:'.mysql_error());
}
mysql_select_db("newimpound",$con);
if (!(mysql_select_db("newimpound", $con)))
showerror( );
$query = "SELECT * FROM newimpound";
if (!($result = @ mysql_query($query, $con)))
// Load the DB utility class
$this->load->dbutil();
// Backup your entire database and assign it to a variable
$backup =& $this->dbutil->backup();
// Load the file helper and write the file to your server
$this->load->helper('file');
write_file('/path/to/mybackup.gz', $backup);
// Load the download helper and send the file to your desktop
$this->load->helper('download');
force_download('mybackup.gz', $backup);
//Setting Backup Preferences
//Backup preferences are set by submitting an array of values to the first parameter of the backup function.
$prefs = array(
'tables' => array('impound_register', 'user_details'), // Array of tables to backup.
'ignore' => array(), // List of tables to omit from the backup
'format' => 'php', // gzip, zip, txt
'filename' => 'mybackup.sql', // File name - NEEDED ONLY WITH ZIP FILES
'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);