Welcome Guest, Not a member yet? Register   Sign In
Question about dbutils 'filename' property
#1

[eluser]coding_hero[/eluser]
Hi, everyone!

Here's my code:
Code:
$filename = "database_backup_" . date("dMY-Gi");

$prefs ['format'] = 'gzip';
$prefs ['filename'] = $filename . ".sql";

$this->load->dbutil();
$this->load->helper('download');
$dbbackup =& $this->dbutil->backup($prefs);

force_download ($filename . ".gz", $dbbackup);

It all works fine, and works like it is supposed to, with the exception of the filename when the .gz file is unzipped. I wanted it to force download on a '.gz' file, and when it's opened, inside would be a '.sql' file. Instead, the file has no extension (the filename is just whatever is set by $filename). Am I misunderstanding what the $prefs['filename'] sets?

Thanks for any help!
#2

[eluser]squarebones[/eluser]
This works for me:

Code:
$this->load->dbutil();
$time = date('mdY_His'); // optional
$filename = 'filename_db_'.$time; // optional
$prefs = array(
    'tables'=>array('tableName1','tableName2','tableName3'), // downloading three different db tables
    'ignore'=>array('ci_sessions'), // don't need this one...
    'format'=>'zip', // for you, it would be 'gz'
    'filename'=>$filename.'.sql', // this is where the file inside the arc gets named
    'add_insert'=>TRUE,
    'newline'=>"\n"
);
@$backup = $this->dbutil->backup($prefs);
write_file('../file_temp/'.$filename.'.sql.zip', $backup);
$this->load->helper('download');
force_download($filename.'.sql.zip', $backup);
#3

[eluser]coding_hero[/eluser]
I was trying to do it without writing it somewhere, since it contains sensitive information and is on a shared server. I wonder if using '.sql.zip' would work any differently?
#4

[eluser]coding_hero[/eluser]
Ahh, naming the zip file .sql.gz seems to have fixed it. I'll see if it works on my client's Windows machines (can you do two extensions on WinXP?). Thanks for the help!




Theme © iAndrew 2016 - Forum software by © MyBB