Backup MySQL database with CodeIgniter

前端 未结 15 1525
一生所求
一生所求 2020-12-30 06:39

I have been looking into the user guide which came with CodeIgniter. I became very interested with the dbutil() method. Particularly the following line of code:

15条回答
  •  情话喂你
    2020-12-30 07:10

    function backup($fileName='db_backup.zip'){
        // 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(FCPATH.'/downloads/'.$fileName, $backup);
    
        // Load the download helper and send the file to your desktop
        $this->load->helper('download');
        force_download($fileName, $backup);
    }
    

    Easy way to backup database using codeigniter

提交回复
热议问题