Conversie codeigniter 4
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
class DownloadDB extends BaseController
|
||||
{
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
if (!defined('AUTHENTICATED') || AUTHENTICATED === false) {
|
||||
die('NO ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
public function index(): ResponseInterface
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$dbutil = \Config\Database::utils();
|
||||
|
||||
$filename = "backupDBOIS_" . date('YmdHis');
|
||||
|
||||
$prefs = [
|
||||
'tables' => [], // Array of tables to backup
|
||||
'ignore' => [], // List of tables to omit from the backup
|
||||
'format' => '', // gzip, zip, txt
|
||||
'filename' => null, // 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 = $dbutil->backup($prefs);
|
||||
|
||||
return $this->response->download($filename . '.sql', $backup);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user