Welcome Guest, Not a member yet? Register   Sign In
Codeigniter dbutil backup question
#1

(This post was last modified: 07-07-2015, 04:56 AM by wolfgang1983.)

I am creating a backup controller form where I can select and unselect table names that I want to back up.

As shown here


PHP Code:
public function backup_database() {
$post_backup $this->input->post('backup[]');

if (!isset(
$post_backup)) {
        
$this->session->set_flashdata('error''Warning: You must select at least one table to backup!');
        
} else {

$this->output->set_header('Pragma: public');
$this->output->set_header('Expires: 0');
$this->output->set_header('Content-Description: File Transfer');
$this->output->set_header('Content-Type: application/octet-stream');
$this->output->set_header('Content-Disposition: attachment; filename=' $this->db->database '_' date('Y-m-d_H-i-s'time()) . '_backup.sql');
$this->output->set_header('Content-Transfer-Encoding: binary');

$this->output->append_output($this->backup_codeigniter($post_backup));

}




Currently I have to add each table name manually like in code below


PHP Code:
public function backup_codeigniter($tables) {
$this->load->dbutil();

$prefs = array(
'tables' => array('user'), 
'ignore' => array(),
'format' => 'txt',
'filename' => $this->db->database .' 'date("Y-m-d-H-i-s").'-backup.sql' 
'add_drop' => TRUE,
'add_insert' => TRUE,
'newline' => "\n" 
);

return 
$this->dbutil->backup($prefs);



I have passed a variable called $tables on the model function.

Question: Instead of me entering the table name manually, How can I pass that variable correct so I do not have to enter each table name manually. Do I need to use array? Is it safe to just have 'tables' => $tables
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
Codeigniter dbutil backup question - by wolfgang1983 - 07-07-2015, 04:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB