Forráskód Böngészése

修复sql批量插入规则

Anyon 4 éve
szülő
commit
82f5d25116
2 módosított fájl, 4 hozzáadás és 3 törlés
  1. 1 0
      app/admin/controller/api/Plugs.php
  2. 3 3
      app/admin/sys.php

+ 1 - 0
app/admin/controller/api/Plugs.php

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

+ 3 - 3
app/admin/sys.php

@@ -45,10 +45,10 @@ try {
                         $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 800);
                         $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) {
-                        $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 150);
-                        $matches[3] = substr(str_replace(['`', '\''], '', $matches[3]), 800);
+                        $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 200);
+                        $matches[3] = substr(str_replace(['`', '\''], '', $matches[3]), 0, 600);
                         $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)) {