summaryrefslogtreecommitdiffstats
path: root/system/database/DB_query_builder.php
diff options
context:
space:
mode:
authortianhe1986 <w1s2j3229@163.com>2017-06-15 05:45:39 +0200
committertianhe1986 <w1s2j3229@163.com>2017-06-15 05:45:39 +0200
commit9f6da3c2f11535fee09dd306ae6b884168e4623b (patch)
tree4673587958753a01a2e184c23120343333e428c6 /system/database/DB_query_builder.php
parente4ed5d950a50fe64223bc6b143301ac87bbde474 (diff)
Ignore LIMIT when using CI_DB_query_builder::count_all_results
Signed-off-by: tianhe1986 <w1s2j3229@163.com>
Diffstat (limited to 'system/database/DB_query_builder.php')
-rw-r--r--system/database/DB_query_builder.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index ef375227c..2e1003395 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1488,6 +1488,15 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$this->qb_orderby = NULL;
}
+ //ignore LIMIT
+ if ($this->qb_limit OR $this->qb_offset)
+ {
+ $limit = $this->qb_limit;
+ $this->qb_limit = NULL;
+ $offset = $this->qb_offset;
+ $this->qb_offset = NULL;
+ }
+
$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby))
? $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')));
@@ -1496,10 +1505,19 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
{
$this->_reset_select();
}
- // If we've previously reset the qb_orderby values, get them back
- elseif ( ! isset($this->qb_orderby))
+ // If we've previously reset the qb_orderby,qb_limit or qb_offset values, get them back
+ else
{
- $this->qb_orderby = $orderby;
+ if ( ! isset($this->qb_orderby))
+ {
+ $this->qb_orderby = $orderby;
+ }
+
+ if ( ! isset($this->qb_limit))
+ {
+ $this->qb_limit = $limit;
+ $this->qb_offset = $offset;
+ }
}
if ($result->num_rows() === 0)