這是我downloding它的正常工作數據庫的壓縮文件的功能,但我想在數據庫中插入這一點,也通過動態選擇SQL文件導入數據庫
public function db_backup(){
date_default_timezone_set('Asia/Calcutta');
$this->load->dbutil();
$prefs = array(
'format' => 'zip',
'add_drop' => TRUE,
'add_insert'=> TRUE,
'newline' => "\n"
);
$backup = $this->dbutil->backup($prefs);
$this->load->helper('file');
$this->load->helper('download');
$this->zip->archive(FCPATH.'backup/database/'.date('Y-m-d-His').'DbBackup.zip');
}
please provide me solution i tried vaious examples nothing works
public function restoredb($id = ''){
$isi_file = file_get_contents('./backups/XXXXXXX.sql'); #here I want to give dynamic path
$query = rtrim($isi_file, "\n;");
$array_query = explode(";", $query);
foreach($array_query as $query){
$this->db->query($query);
}
}
將其導入到數據庫以上功能恢復數據庫,但沒有工作,因爲我想
你可以訪問你的PHP配置了shell_exec? –
你能告訴如何訪問? – eliana