Merge pull request #5282 from pgee70/patch-1
Fix ORDER BY clauses being reset by count_all_results()
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 81603bf..72bd4e7 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1405,7 +1405,7 @@
// for selecting COUNT(*) ...
$qb_orderby = $this->qb_orderby;
$qb_cache_orderby = $this->qb_cache_orderby;
- $this->qb_orderby = $this->qb_cache_orderby = NULL;
+ $this->qb_orderby = $this->qb_cache_orderby = array();
$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR $this->qb_limit OR $this->qb_offset)
? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")