Files
dbois/application/controllers/utils/DownloadDB.php
T
2019-01-02 17:28:07 +01:00

41 lines
1.1 KiB
PHP

<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 2019-01-02
* Time: 17:13
*/
class DownloadDB extends MY_Controller {
public function __construct()
{
parent::__construct();
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
}
public function index()
{
$this->load->dbutil();
$filename = "backupDBOIS_" . date( 'YmdHis' );
$prefs = [
'tables' => [], // Array of tables to backup.
'ignore' => [], // List of tables to omit from the backup
'format' => '', // gzip, zip, txt
'filename' => NULL, // 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
];
$backup = $this->dbutil->backup( $prefs );
// Load the download helper and send the file to your desktop
$this->load->helper( 'download' );
force_download( $filename . '.sql', $backup );
}
}