02-22-2021, 05:34 PM
(This post was last modified: 02-22-2021, 05:36 PM by masanabdiwicaksono.)
Hi,
How to use backup function in codeigniter 4, i am using method from codeigniter 3 and it won't work.
Showing Error : CodeIgniter\Database\Exceptions\DatabaseException Unsupported feature of the database platform you are using.
Thank You
How to use backup function in codeigniter 4, i am using method from codeigniter 3 and it won't work.
Showing Error : CodeIgniter\Database\Exceptions\DatabaseException Unsupported feature of the database platform you are using.
Code:
public function backup()
{
$model = new class extends \CodeIgniter\Model
{
protected $table = 'tb_envelope';
protected $primaryKey = 'id_envelope';
};
$db = \Closure::bind(function ($model) {
return $model->db;
}, null, $model)($model);
$util = (new \CodeIgniter\Database\Database())->loadUtils($db);
$date= date('YmdS-His');
$config = [
'format' => 'zip',
'filename' => 'My_' . $date . '_db.sql',
'add_drop' => TRUE,
'add_insert' => TRUE,
'newline' => "\n",
'foreign_key_checks' => FALSE,
];
$backup = $util->backup($config);
$file_name= 'My_' . $tanggal . '.zip';
helper('download');
$this->response->download($file_name, $backup);
Thank You
