public function actionRestore($id = null)
{
$model = new FormBackupFile();
$comp = $this->loadModel($this->company);
if (isset($_POST['FormBackupFile'])) {
$bkup = Company::getFilePath() . "tmp.zip";
$model->file = $_POST['FormBackupFile']['file'];
$model->file = \yii\web\UploadedFile::getInstance($model, 'file');
if ($model->file->saveAs($bkup)) {
$comp->restore($bkup);
return $this->redirect(\yii\helpers\BaseUrl::base() . '/settings/dashboard');
}
}
if ($id != null) {
$file = Files::findOne($id);
if ($file != null) {
$comp->restore($file->getFullFilePath());
$this->redirect(\yii\helpers\BaseUrl::base() . '/settings/dashboard');
} else {
throw new \yii\web\HttpException(500, 'The backup file does not exist.');
}
}
//read file
//if DROP TABLE IF EXISTS `
//if CREATE TABLE `
//INSERT INTO `
return $this->render('backupRestore', array('model' => $model));
}