summaryrefslogtreecommitdiffstats
path: root/system/database/DB_driver.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-07-19 15:11:17 +0200
committerAndrey Andreev <narf@bofh.bg>2012-07-19 15:11:17 +0200
commite8be24b1c4bc3dd6fb78133d15857e2b23972c5b (patch)
tree9e5ab0530ed159cb4f58a7c72c47ce1e821f1f0d /system/database/DB_driver.php
parent822317b2a8a9872819cd22de6782b44f5c267d2f (diff)
Fix CI_DB_driver::_get_operator()
Diffstat (limited to 'system/database/DB_driver.php')
-rw-r--r--system/database/DB_driver.php39
1 files changed, 19 insertions, 20 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 371b6db96..f848cfe4e 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1157,29 +1157,28 @@ abstract class CI_DB_driver {
*/
protected function _get_operator($str)
{
- static $_operators = array(
- '\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
- '\s*<>?\s*', // <, <>
- '\s*>\s*', // >
- '\s+IS NULL', // IS NULL
- '\s+IS NOT NULL', // IS NOT NULL
- '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value
- '\s+IN\s*\([^\)]+\)', // IN(list)
- '\s+NOT IN\s*\([^\)]+\)' // NOT IN (list)
- );
+ static $_operators;
- static $_like = array(
- '\s+LIKE\s+\S+', // LIKE 'expr'
- '\s+NOT LIKE\s+\S+', // NOT LIKE 'expr'
- );
-
- if ($this->_like_escape_str !== '')
+ if (empty($_operators))
{
- $_like[0] .= preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)));
- $_like[1] .= preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)));
- }
+ $_les = ($this->_like_escape_str !== '')
+ ? preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)))
+ : '';
- $_operators = array_merge($_operators, $_like);
+ $_operators = array(
+ '\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
+ '\s*<>?\s*', // <, <>
+ '\s*>\s*', // >
+ '\s+IS NULL', // IS NULL
+ '\s+IS NOT NULL', // IS NOT NULL
+ '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value
+ '\s+IN\s*\([^\)]+\)', // IN(list)
+ '\s+NOT IN\s*\([^\)]+\)', // NOT IN (list)
+ '\s+LIKE\s+\S+'.$_les, // LIKE 'expr'[ ESCAPE '%s']
+ '\s+NOT LIKE\s+\S+'.$_les // NOT LIKE 'expr'[ ESCAPE '%s']
+ );
+
+ }
return preg_match('/'.implode('|', $_operators).'/i', $str, $match)
? $match[0] : FALSE;