@@ -244,6 +244,20 @@ class BaseBuilder
244244 'RIGHT OUTER ' ,
245245 ];
246246
247+ /**
248+ * Strings that determine if a string represents a literal value or a field name
249+ *
250+ * @var string[]
251+ */
252+ protected $ isLiteralStr = [];
253+
254+ /**
255+ * RegExp used to get operators
256+ *
257+ * @var string[]
258+ */
259+ protected $ pregOperators = [];
260+
247261 /**
248262 * Constructor
249263 *
@@ -2515,13 +2529,11 @@ protected function isLiteral(string $str): bool
25152529 return true ;
25162530 }
25172531
2518- static $ _str ;
2519-
2520- if (empty ($ _str )) {
2521- $ _str = ($ this ->db ->escapeChar !== '" ' ) ? ['" ' , "' " ] : ["' " ];
2532+ if ($ this ->isLiteralStr === []) {
2533+ $ this ->isLiteralStr = $ this ->db ->escapeChar !== '" ' ? ['" ' , "' " ] : ["' " ];
25222534 }
25232535
2524- return in_array ($ str [0 ], $ _str , true );
2536+ return in_array ($ str [0 ], $ this -> isLiteralStr , true );
25252537 }
25262538
25272539 /**
@@ -2600,7 +2612,10 @@ protected function resetWrite()
26002612 */
26012613 protected function hasOperator (string $ str ): bool
26022614 {
2603- return (bool ) preg_match ('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i ' , trim ($ str ));
2615+ return preg_match (
2616+ '/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i ' ,
2617+ trim ($ str )
2618+ ) === 1 ;
26042619 }
26052620
26062621 /**
@@ -2610,11 +2625,11 @@ protected function hasOperator(string $str): bool
26102625 */
26112626 protected function getOperator (string $ str , bool $ list = false )
26122627 {
2613- static $ _operators ;
2614-
2615- if ( empty ( $ _operators )) {
2616- $ _les = ( $ this -> db -> likeEscapeStr !== '' ) ? ' \s+ ' . preg_quote ( trim ( sprintf ( $ this -> db -> likeEscapeStr , $ this -> db -> likeEscapeChar )), ' / ' ) : '' ;
2617- $ _operators = [
2628+ if ( $ this -> pregOperators === []) {
2629+ $ _les = $ this -> db -> likeEscapeStr !== ''
2630+ ? ' \s+ ' . preg_quote ( trim ( sprintf ( $ this -> db -> likeEscapeStr , $ this -> db -> likeEscapeChar )), ' / ' )
2631+ : '' ;
2632+ $ this -> pregOperators = [
26182633 '\s*(?:<|>|!)?=\s* ' , // =, <=, >=, !=
26192634 '\s*<>?\s* ' , // <, <>
26202635 '\s*>\s* ' , // >
@@ -2630,7 +2645,11 @@ protected function getOperator(string $str, bool $list = false)
26302645 ];
26312646 }
26322647
2633- return preg_match_all ('/ ' . implode ('| ' , $ _operators ) . '/i ' , $ str , $ match ) ? ($ list ? $ match [0 ] : $ match [0 ][0 ]) : false ;
2648+ return preg_match_all (
2649+ '/ ' . implode ('| ' , $ this ->pregOperators ) . '/i ' ,
2650+ $ str ,
2651+ $ match
2652+ ) ? ($ list ? $ match [0 ] : $ match [0 ][0 ]) : false ;
26342653 }
26352654
26362655 /**
0 commit comments