exec($line); } catch (\Throwable $th) { Log::info($th->getMessage()); } } } } /** * 获取数据库文件表名 * @param string $sqlFile * @return array */ public static function getSqlTables(string $sqlFile): array { $regex = "/^CREATE\s+TABLE\s+(IF\s+NOT\s+EXISTS\s+)?`?([a-zA-Z_]+)`?/mi"; $tables = []; if (is_file($sqlFile)) { preg_match_all($regex, file_get_contents($sqlFile), $matches); if (isset($matches[2])) { foreach ($matches[2] as $match) { $tables[] = str_replace('__PREFIX__', get_env('DATABASE_PREFIX'), $match); } } } return $tables; } }