@@ -238,6 +238,13 @@ abstract class BaseConnection implements ConnectionInterface
238238 */
239239 public $ likeEscapeChar = '! ' ;
240240
241+ /**
242+ * RegExp used to escape identifiers
243+ *
244+ * @var array
245+ */
246+ protected $ pregEscapeChar = [];
247+
241248 /**
242249 * Holds previously looked up data
243250 * for performance reasons.
@@ -1119,29 +1126,27 @@ public function escapeIdentifiers($item)
11191126 return $ item ;
11201127 }
11211128
1122- static $ pregEc = [];
1123-
1124- if (empty ($ pregEc )) {
1129+ if (empty ($ this ->pregEscapeChar )) {
11251130 if (is_array ($ this ->escapeChar )) {
1126- $ pregEc = [
1131+ $ this -> pregEscapeChar = [
11271132 preg_quote ($ this ->escapeChar [0 ], '/ ' ),
11281133 preg_quote ($ this ->escapeChar [1 ], '/ ' ),
11291134 $ this ->escapeChar [0 ],
11301135 $ this ->escapeChar [1 ],
11311136 ];
11321137 } else {
1133- $ pregEc [0 ] = $ pregEc [1 ] = preg_quote ($ this ->escapeChar , '/ ' );
1134- $ pregEc [2 ] = $ pregEc [3 ] = $ this ->escapeChar ;
1138+ $ this -> pregEscapeChar [0 ] = $ this -> pregEscapeChar [1 ] = preg_quote ($ this ->escapeChar , '/ ' );
1139+ $ this -> pregEscapeChar [2 ] = $ this -> pregEscapeChar [3 ] = $ this ->escapeChar ;
11351140 }
11361141 }
11371142
11381143 foreach ($ this ->reservedIdentifiers as $ id ) {
11391144 if (strpos ($ item , '. ' . $ id ) !== false ) {
1140- return preg_replace ('/ ' . $ pregEc [0 ] . '?([^ ' . $ pregEc [1 ] . '\.]+) ' . $ pregEc [1 ] . '?\./i ' , $ pregEc [2 ] . '$1 ' . $ pregEc [3 ] . '. ' , $ item );
1145+ return preg_replace ('/ ' . $ this -> pregEscapeChar [0 ] . '?([^ ' . $ this -> pregEscapeChar [1 ] . '\.]+) ' . $ this -> pregEscapeChar [1 ] . '?\./i ' , $ this -> pregEscapeChar [2 ] . '$1 ' . $ this -> pregEscapeChar [3 ] . '. ' , $ item );
11411146 }
11421147 }
11431148
1144- return preg_replace ('/ ' . $ pregEc [0 ] . '?([^ ' . $ pregEc [1 ] . '\.]+) ' . $ pregEc [1 ] . '?(\.)?/i ' , $ pregEc [2 ] . '$1 ' . $ pregEc [3 ] . '$2 ' , $ item );
1149+ return preg_replace ('/ ' . $ this -> pregEscapeChar [0 ] . '?([^ ' . $ this -> pregEscapeChar [1 ] . '\.]+) ' . $ this -> pregEscapeChar [1 ] . '?(\.)?/i ' , $ this -> pregEscapeChar [2 ] . '$1 ' . $ this -> pregEscapeChar [3 ] . '$2 ' , $ item );
11451150 }
11461151
11471152 /**
0 commit comments