From 5f81769456dcdaabe349cd09addaa121fc2079a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E8=BE=B0=E8=BD=A9?= Date: Fri, 7 Jun 2024 13:22:14 +0800 Subject: [PATCH] * [refac,0.5h] Use full table preg_replace for duckdb. --- lib/duckdb/duckdb.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/duckdb/duckdb.class.php b/lib/duckdb/duckdb.class.php index dcc9be1b64..66e67da7ed 100644 --- a/lib/duckdb/duckdb.class.php +++ b/lib/duckdb/duckdb.class.php @@ -190,9 +190,13 @@ class duckdb { if(empty($this->tables)) return $sql; - $replaceTables = array(); - foreach($this->tables as $table) $replaceTables[] = "'{$this->tmpPath}{$table}.parquet'"; - $sql = str_replace($this->tables, $replaceTables, $sql); + foreach($this->tables as $table) + { + $pattern = "/\b{$table}\b/"; + $replace = "'{$this->tmpPath}{$table}.parquet'"; + + $sql = preg_replace($pattern, $replace, $sql); + } return $sql; }