diff options
author | Andrey Andreev <narf@devilix.net> | 2014-09-29 19:07:15 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-09-29 19:07:15 +0200 |
commit | 5bf4dcde18ae0d584c2dc701ccc8e43124549130 (patch) | |
tree | edc1856ccc580c280fabe2ea009f8385b41d212b | |
parent | 970b3836071f1b74d2c98bdc0656c2d9699c9ac0 (diff) |
Close #3194
-rw-r--r-- | system/database/DB_query_builder.php | 4 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 30882fadc..2096ffd60 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -661,6 +661,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // value appears not to have been set, assign the test to IS NULL $k .= ' IS NULL'; } + elseif (preg_match('/\s*(!?=|<>)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE)) + { + $k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL'); + } $this->{$qb_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape); if ($this->qb_caching === TRUE) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2b807eb49..a3b354961 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -187,6 +187,7 @@ Release Date: Not Released - Changed ``limit()`` to ignore NULL values instead of always casting to integer. - Changed ``offset()`` to ignore empty values instead of always casting to integer. - Methods ``insert_batch()`` and ``update_batch()`` now return an integer representing the number of rows affected by them. + - Methods ``where()``, ``or_where()``, ``having()`` and ``or_having()`` now convert trailing ``=`` and ``<>``, ``!=`` SQL operators to ``IS NULL`` and ``IS NOT NULL`` respectively when the supplied comparison value is ``NULL``. - :doc:`Database Results <database/results>` changes include: |