修复sql批量插入规则

This commit is contained in:
Anyon 2020-09-21 18:36:32 +08:00
parent 496f5a1836
commit 82f5d25116
2 changed files with 4 additions and 3 deletions

View File

@ -152,6 +152,7 @@ class Plugs extends Controller
$this->app->db->name('SystemConfig')->insertAll($alldata); $this->app->db->name('SystemConfig')->insertAll($alldata);
}); });
$this->app->cache->delete('SystemConfig'); $this->app->cache->delete('SystemConfig');
$GLOBALS['oplogs'] = [];
$this->success('清理系统配置成功!'); $this->success('清理系统配置成功!');
} catch (HttpResponseException $exception) { } catch (HttpResponseException $exception) {
throw $exception; throw $exception;

View File

@ -45,10 +45,10 @@ try {
$matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 800); $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 800);
$GLOBALS['oplogs'][] = SystemService::instance()->getOplog("添加 {$matches[1]} 数据", $matches[2]); $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("添加 {$matches[1]} 数据", $matches[2]);
} }
} elseif (preg_match('/^INSERT\s*INTO\s*`(.*?)`\s*\((.*?)\)\s*VALUES\s+\((.*?)\)\s*$/i', $sqlstr, $matches)) { } elseif (preg_match('/^INSERT\s*INTO\s+`(.*?)`\s+(.*?)\s+VALUES\s+(.*?)\s*$/i', $sqlstr, $matches)) {
if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) { if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) {
$matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 150); $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 200);
$matches[3] = substr(str_replace(['`', '\''], '', $matches[3]), 800); $matches[3] = substr(str_replace(['`', '\''], '', $matches[3]), 0, 600);
$GLOBALS['oplogs'][] = SystemService::instance()->getOplog("添加 {$matches[1]} 数据", "{$matches[2]} VALUES {$matches[3]}"); $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("添加 {$matches[1]} 数据", "{$matches[2]} VALUES {$matches[3]}");
} }
} elseif (preg_match('/^UPDATE\s+`(.*?)`\s+SET\s+(.*?)\s+WHERE\s+(.*?)\s*$/i', $sqlstr, $matches)) { } elseif (preg_match('/^UPDATE\s+`(.*?)`\s+SET\s+(.*?)\s+WHERE\s+(.*?)\s*$/i', $sqlstr, $matches)) {