I want to backup a table in my database with codeigniter. I found this Guide, and programmed the function accordning to the Guide. The Problem is, that i dont get an error and i can't find the backup anywhere on my Server.
My function looks like this:
function backup_Eventtable() {
$this->load->dbutil();
$prefs = array(
'tables' => array('MYTABLE'), // Array of tables to backup.
'ignore' => array(), // List of tables to omit from the backup
'format' => 'txt', // gzip, zip, txt
'filename' => 'mybackup.sql', // 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);
//I tried it with and without the next 2 Lines.
$this->load->helper('file');
write_file('/uploads/EventBackup/mybackup.sql', $backup);
}
I just checked the appache error log and found this line:
[Fri Mar 07 14:28:37 2014] [error] [client 192.168.242.116] PHP Fatal error: Call to undefined method CI_DB_mysql_driver::backup() in /var/www/html/kaufleuten/admin/system/application/models/eventmodel.php on line 764, referer: http://devzh2.energy.local:8093/admin/events/edit/4002
database.php looks like this:
$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "myusername";
$db['default']['password'] = "mypassword";
$db['default']['database'] = "kaufleuten_typo3";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "/var/www/html/kaufleuten/admin/cache";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";