功能更新
This commit is contained in:
@@ -26,7 +26,7 @@ class Database extends Base {
|
||||
/* 数据还原 */
|
||||
case 'import':
|
||||
//列出备份文件列表
|
||||
$path = \think\facade\Cache::get('system_config_data.data_backup_path');
|
||||
$path = $this->app->getRuntimePath() . DIRECTORY_SEPARATOR . 'backup';
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path, 0755, true);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class Database extends Base {
|
||||
*/
|
||||
public function optimize($tables = null) {
|
||||
if ($tables) {
|
||||
$Db = \think\Db::connect();
|
||||
$Db = \think\facade\Db::connect();
|
||||
if (is_array($tables)) {
|
||||
$tables = implode('`,`', $tables);
|
||||
$list = $Db->query("OPTIMIZE TABLE `{$tables}`");
|
||||
@@ -112,7 +112,7 @@ class Database extends Base {
|
||||
*/
|
||||
public function repair($tables = null) {
|
||||
if ($tables) {
|
||||
$Db = \think\Db::connect();
|
||||
$Db = \think\facade\Db::connect();
|
||||
if (is_array($tables)) {
|
||||
$tables = implode('`,`', $tables);
|
||||
$list = $Db->query("REPAIR TABLE `{$tables}`");
|
||||
@@ -142,7 +142,7 @@ class Database extends Base {
|
||||
public function del($time = 0) {
|
||||
if ($time) {
|
||||
$name = date('Ymd-His', $time) . '-*.sql*';
|
||||
$path = realpath(config('DATA_BACKUP_PATH')) . DIRECTORY_SEPARATOR . $name;
|
||||
$path = $this->app->getRuntimePath() . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . $name;
|
||||
array_map("unlink", glob($path));
|
||||
if (count(glob($path))) {
|
||||
return $this->error('备份文件删除失败,请检查权限!');
|
||||
@@ -163,7 +163,7 @@ class Database extends Base {
|
||||
public function export($tables = null, $id = null, $start = null) {
|
||||
if ($this->request->isPost() && !empty($tables) && is_array($tables)) {
|
||||
//初始化
|
||||
$path = config('data_backup_path');
|
||||
$path = $this->app->getRuntimePath() . DIRECTORY_SEPARATOR . 'backup';
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path, 0755, true);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class Database extends Base {
|
||||
//初始化
|
||||
//获取备份文件信息
|
||||
$name = date('Ymd-His', $time) . '-*.sql*';
|
||||
$path = realpath(config('data_backup_path')) . DIRECTORY_SEPARATOR . $name;
|
||||
$path = $this->app->getRuntimePath() . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . $name;
|
||||
$files = glob($path);
|
||||
$list = array();
|
||||
foreach ($files as $name) {
|
||||
@@ -257,7 +257,7 @@ class Database extends Base {
|
||||
} elseif (is_numeric($part) && is_numeric($start)) {
|
||||
$list = session('backup_list');
|
||||
|
||||
$db = new \com\Database($list[$part], array('path' => realpath(config('data_backup_path')) . DIRECTORY_SEPARATOR, 'compress' => $list[$part][2]));
|
||||
$db = new \com\Database($list[$part], array('path' => $this->app->getRuntimePath() . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR, 'compress' => $list[$part][2]));
|
||||
|
||||
$start = $db->import($start);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user