From 5f8c0c1f638c40f56251b1f805336dbd5f80e19f Mon Sep 17 00:00:00 2001 From: yaoshanliang <1329517386@qq.com> Date: Sat, 14 Mar 2015 12:44:18 +0800 Subject: add a judgment of whether reset select --- system/database/DB_query_builder.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 79cbfb3ad..894d7ddb5 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1355,7 +1355,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param string * @return int */ - public function count_all_results($table = '') + public function count_all_results($table = '', $reset = true) { if ($table !== '') { @@ -1366,7 +1366,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $result = ($this->qb_distinct === TRUE) ? $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'))); - $this->_reset_select(); + if($reset) + { + $this->_reset_select(); + } if ($result->num_rows() === 0) { -- cgit v1.2.3-24-g4f1b From 9971e7bc326df1a14e7bb17b1290e5fe5bfd5c60 Mon Sep 17 00:00:00 2001 From: yaoshanliang <1329517386@qq.com> Date: Sat, 14 Mar 2015 13:09:16 +0800 Subject: add a judgment of whether reset select --- system/database/DB_query_builder.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 894d7ddb5..3d4a8576c 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1366,10 +1366,11 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $result = ($this->qb_distinct === TRUE) ? $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'))); - if($reset) - { - $this->_reset_select(); - } + + if($reset) + { + $this->_reset_select(); + } if ($result->num_rows() === 0) { -- cgit v1.2.3-24-g4f1b From 19c2847a7c24daa0c2999b77ce82ae199afadda9 Mon Sep 17 00:00:00 2001 From: yaoshanliang <1329517386@qq.com> Date: Sun, 15 Mar 2015 10:42:18 +0800 Subject: add changelog and documentation for adding an optional parameter to ``count_all_results()`` --- system/database/DB_query_builder.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 3d4a8576c..facaf0e4c 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1353,9 +1353,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * returned by an Query Builder query. * * @param string + * @param bool TRUE: resets QB values; FALSE: leave QB vaules alone * @return int */ - public function count_all_results($table = '', $reset = true) + public function count_all_results($table = '', $reset = TRUE) { if ($table !== '') { @@ -1367,10 +1368,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver { ? $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'))); - if($reset) - { - $this->_reset_select(); - } + if($reset === TRUE) + { + $this->_reset_select(); + } if ($result->num_rows() === 0) { -- cgit v1.2.3-24-g4f1b From 2f164058e3ffa429747e27b284f67f2e71809f52 Mon Sep 17 00:00:00 2001 From: yaoshanliang <1329517386@qq.com> Date: Mon, 16 Mar 2015 16:48:15 +0800 Subject: update documentation in database/query_builder.rst, change 2 tabs + 4 spaces to 3 tabs. --- system/database/DB_query_builder.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index facaf0e4c..e5ffef2bb 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1353,7 +1353,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * returned by an Query Builder query. * * @param string - * @param bool TRUE: resets QB values; FALSE: leave QB vaules alone + * @param bool the reset clause * @return int */ public function count_all_results($table = '', $reset = TRUE) @@ -1368,9 +1368,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { ? $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'))); - if($reset === TRUE) + if ($reset === TRUE) { - $this->_reset_select(); + $this->_reset_select(); } if ($result->num_rows() === 0) -- cgit v1.2.3-24-g4f1b