|
|
|
@ -4,6 +4,7 @@ declare (strict_types = 1); |
|
|
|
namespace app\controller; |
|
|
|
|
|
|
|
use app\BaseController; |
|
|
|
use app\logic\Backups; |
|
|
|
use think\facade\Db; |
|
|
|
use think\facade\Request; |
|
|
|
use think\facade\Session; |
|
|
|
@ -103,10 +104,21 @@ class AdminUser extends BaseController |
|
|
|
*/ |
|
|
|
public function clean() |
|
|
|
{ |
|
|
|
$tableArr = config('database.all_table_name'); |
|
|
|
# 获取所有表名 |
|
|
|
$tables = Db::query('SHOW TABLES'); |
|
|
|
$tablesNameArr = []; |
|
|
|
foreach ($tables as $table) { |
|
|
|
if(isset($table['Tables_in_guaguale']) && !empty($table['Tables_in_guaguale'])) { |
|
|
|
$tablesNameArr[] = $table['Tables_in_guaguale']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
# 备份数据表数据 |
|
|
|
#if (!$result['status']) return $this->renderError('清除失败'); |
|
|
|
|
|
|
|
foreach ($tableArr as $tableName) { |
|
|
|
Db::execute("TRUNCATE TABLE {$tableName}"); |
|
|
|
# 清空 |
|
|
|
foreach ($tablesNameArr as $tableName) { |
|
|
|
Db::query("TRUNCATE TABLE {$tableName}"); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderSuccess('已清除成功'); |
|
|
|
|