@@ -339,6 +339,20 @@ abstract class CI_DB_driver {
339339 */
340340 protected $ _like_escape_chr = '! ' ;
341341
342+ /**
343+ * RegExp used to escape identifiers
344+ *
345+ * @var array
346+ */
347+ protected $ _preg_escape_char = array ();
348+
349+ /**
350+ * RegExp used to get operators
351+ *
352+ * @var string[]
353+ */
354+ protected $ _preg_operators = array ();
355+
342356 /**
343357 * ORDER BY random keyword
344358 *
@@ -1415,13 +1429,11 @@ public function escape_identifiers($item)
14151429 return $ item ;
14161430 }
14171431
1418- static $ preg_ec = array ();
1419-
1420- if (empty ($ preg_ec ))
1432+ if (empty ($ this ->_preg_escape_char ))
14211433 {
14221434 if (is_array ($ this ->_escape_char ))
14231435 {
1424- $ preg_ec = array (
1436+ $ this -> _preg_escape_char = array (
14251437 preg_quote ($ this ->_escape_char [0 ], '/ ' ),
14261438 preg_quote ($ this ->_escape_char [1 ], '/ ' ),
14271439 $ this ->_escape_char [0 ],
@@ -1430,20 +1442,20 @@ public function escape_identifiers($item)
14301442 }
14311443 else
14321444 {
1433- $ preg_ec [0 ] = $ preg_ec [1 ] = preg_quote ($ this ->_escape_char , '/ ' );
1434- $ preg_ec [2 ] = $ preg_ec [3 ] = $ this ->_escape_char ;
1445+ $ this -> _preg_escape_char [0 ] = $ this -> _preg_escape_char [1 ] = preg_quote ($ this ->_escape_char , '/ ' );
1446+ $ this -> _preg_escape_char [2 ] = $ this -> _preg_escape_char [3 ] = $ this ->_escape_char ;
14351447 }
14361448 }
14371449
14381450 foreach ($ this ->_reserved_identifiers as $ id )
14391451 {
14401452 if (strpos ($ item , '. ' .$ id ) !== FALSE )
14411453 {
1442- return preg_replace ('/ ' .$ preg_ec [0 ].'?([^ ' .$ preg_ec [1 ].'\.]+) ' .$ preg_ec [1 ].'?\./i ' , $ preg_ec [2 ].'$1 ' .$ preg_ec [3 ].'. ' , $ item );
1454+ return preg_replace ('/ ' .$ this -> _preg_escape_char [0 ].'?([^ ' .$ this -> _preg_escape_char [1 ].'\.]+) ' .$ this -> _preg_escape_char [1 ].'?\./i ' , $ this -> _preg_escape_char [2 ].'$1 ' .$ this -> _preg_escape_char [3 ].'. ' , $ item );
14431455 }
14441456 }
14451457
1446- return preg_replace ('/ ' .$ preg_ec [0 ].'?([^ ' .$ preg_ec [1 ].'\.]+) ' .$ preg_ec [1 ].'?(\.)?/i ' , $ preg_ec [2 ].'$1 ' .$ preg_ec [3 ].'$2 ' , $ item );
1458+ return preg_replace ('/ ' .$ this -> _preg_escape_char [0 ].'?([^ ' .$ this -> _preg_escape_char [1 ].'\.]+) ' .$ this -> _preg_escape_char [1 ].'?(\.)?/i ' , $ this -> _preg_escape_char [2 ].'$1 ' .$ this -> _preg_escape_char [3 ].'$2 ' , $ item );
14471459 }
14481460
14491461 // --------------------------------------------------------------------
@@ -1562,14 +1574,12 @@ protected function _has_operator($str)
15621574 */
15631575 protected function _get_operator ($ str )
15641576 {
1565- static $ _operators ;
1566-
1567- if (empty ($ _operators ))
1577+ if (empty ($ this ->_preg_operators ))
15681578 {
15691579 $ _les = ($ this ->_like_escape_str !== '' )
15701580 ? '\s+ ' .preg_quote (trim (sprintf ($ this ->_like_escape_str , $ this ->_like_escape_chr )), '/ ' )
15711581 : '' ;
1572- $ _operators = array (
1582+ $ this -> _preg_operators = array (
15731583 '\s*(?:<|>|!)?=\s* ' , // =, <=, >=, !=
15741584 '\s*<>?\s* ' , // <, <>
15751585 '\s*>\s* ' , // >
@@ -1587,7 +1597,7 @@ protected function _get_operator($str)
15871597
15881598 }
15891599
1590- return preg_match ('/ ' .implode ('| ' , $ _operators ).'/i ' , $ str , $ match )
1600+ return preg_match ('/ ' .implode ('| ' , $ this -> _preg_operators ).'/i ' , $ str , $ match )
15911601 ? $ match [0 ] : FALSE ;
15921602 }
15931603
0 commit comments