CodeIgniter Forums
Backup mysql database with codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Backup mysql database with codeigniter (/thread-56543.html)



Backup mysql database with codeigniter - El Forum - 12-30-2012

[eluser]muttalebm[/eluser]
I have been looking into the user guide which came with codeigniter. I became very interest with the dbutil(). Particularly the following line of codes:

Code:
// 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);
It is supposed to backup the currently loaded MySQL database. But unfortunately, it is not working and i get the following message:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$dbutil

Filename: views/view.php

Line Number: 10

Fatal error: Call to a member function backup() on a non-object in C:\xampp\htdocs\CodeIgniter\application\views\view.php on line 10

what am i missing here. Any help would be really appreciated

~muttalebm


Backup mysql database with codeigniter - El Forum - 12-30-2012

[eluser]InsiteFX[/eluser]
You should not be calling any of that in your view file.

All the dbutil methods should be called in your controller then output what you want to your view.