summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/database/DB_driver.php5
-rw-r--r--system/database/DB_query_builder.php12
2 files changed, 10 insertions, 7 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 12ab5bb2a..62cea758e 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1440,7 +1440,7 @@ abstract class CI_DB_driver {
*/
protected function _has_operator($str)
{
- return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str));
+ return (bool) preg_match('/(<|>|!|=|\sIS\s|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str));
}
// --------------------------------------------------------------------
@@ -1464,8 +1464,7 @@ abstract class CI_DB_driver {
'\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
'\s*<>?\s*', // <, <>
'\s*>\s*', // >
- '\s+IS NULL', // IS NULL
- '\s+IS NOT NULL', // IS NOT NULL
+ '\s+IS(?:\sNOT)?(?:\sNULL)?', // IS[ NOT] NULL
'\s+EXISTS\s*\([^\)]+\)', // EXISTS(sql)
'\s+NOT EXISTS\s*\([^\)]+\)', // NOT EXISTS(sql)
'\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index f11f84627..4e37e4c03 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -663,11 +663,15 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
}
else
{
- $operator = trim($this->_get_operator($k));
-
- if ($operator === '<>' OR $operator === '!=')
+ $operator = $this->_get_operator($k);
+ if (stripos($operator, 'NULL') === FALSE)
{
- $k = str_replace($operator, ' IS NOT NULL', $k);
+ $op = strrpos($k, $operator);
+ if (strlen($k) === ($op + strlen($operator)))
+ {
+ $operator = strtr($operator, array('<>' => 'IS NOT', '!=' => 'IS NOT'));
+ $k = substr($k, 0, $op).rtrim($operator).' NULL';
+ }
}
}