update app/admin/controller/File.php.

修复在更新表的同时在子查询中引用同一个表报错

Signed-off-by: 承诺 <1322522027@qq.com>
This commit is contained in:
承诺 2025-08-20 02:00:22 +00:00 committed by Gitee
parent 52e7c2faac
commit a122a25a83
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -110,7 +110,7 @@ class File extends Controller
{
$map = ['issafe' => 0, 'uuid' => AdminService::getUserId()];
$subQuery = SystemFile::mk()->fieldRaw('MAX(id) AS id')->where($map)->group('type, xkey')->buildSql();
SystemFile::mk()->where($map)->whereRaw("id NOT IN ({$subQuery})")->delete();
SystemFile::mk()->where($map)->whereRaw("id NOT IN (SELECT id FROM ({$subQuery}) AS file_table)")->delete();
$this->success('清理重复文件成功!');
}
}