summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-11-04 14:52:16 +0100
committerAndrey Andreev <narf@devilix.net>2015-11-04 14:52:16 +0100
commit939f1a27f3e70170326f6acbc50c0e1c96e52fd3 (patch)
tree2b10dc6d5318e26de42196e0dd6e467e0d575a50
parent6afbb3a9f186f912d5105aea704bb58c55931762 (diff)
Fix #4212
-rw-r--r--system/database/DB_query_builder.php2
-rw-r--r--user_guide_src/source/changelog.rst5
2 files changed, 6 insertions, 1 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index cf1100d27..7a3d2f594 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1379,7 +1379,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$this->from($table);
}
- $result = ($this->qb_distinct === TRUE)
+ $result = ($this->qb_distinct === TRUE OR ! empty($this->qb_orderby))
? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
: $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows')));
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 20d85a9ab..f632f72dd 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -7,6 +7,11 @@ Version 3.0.4
Release Date: Not Released
+Bug fixes for 3.0.4
+-------------------
+
+- Fixed a bug (#4212) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` could fail if an ``ORDER BY`` condition is used.
+
Version 3.0.3
=============