summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-12-11 15:27:15 +0100
committerAndrey Andreev <narf@devilix.net>2014-12-11 15:27:15 +0100
commit4a587f5bf3d7c26112e0cf8f8d54299784ce60d0 (patch)
tree6db8f901427dbf2a41b6eb869d2c380f87355829
parent75818dfe84f9c6e3de0cb798b77bf8e68cd7f435 (diff)
Add method chaining support to QB cache methods
-rw-r--r--system/database/DB_query_builder.php42
-rw-r--r--user_guide_src/source/changelog.rst1
2 files changed, 23 insertions, 20 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 1c0aed693..fdea51bdd 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1215,7 +1215,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
* @param int $offset OFFSET value
* @return CI_DB_query_builder
*/
- public function limit($value, $offset = FALSE)
+ public function limit($value, $offset = 0)
{
is_null($value) OR $this->qb_limit = (int) $value;
empty($offset) OR $this->qb_offset = (int) $offset;
@@ -2509,11 +2509,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
*
* Starts QB caching
*
- * @return void
+ * @return CI_DB_query_builder
*/
public function start_cache()
{
$this->qb_caching = TRUE;
+ return $this;
}
// --------------------------------------------------------------------
@@ -2523,11 +2524,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
*
* Stops QB caching
*
- * @return void
+ * @return CI_DB_query_builder
*/
public function stop_cache()
{
$this->qb_caching = FALSE;
+ return $this;
}
// --------------------------------------------------------------------
@@ -2537,7 +2539,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
*
* Empties the QB cache
*
- * @return void
+ * @return CI_DB_query_builder
*/
public function flush_cache()
{
@@ -2553,6 +2555,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
'qb_cache_exists' => array(),
'qb_cache_no_escape' => array()
));
+
+ return $this;
}
// --------------------------------------------------------------------
@@ -2680,20 +2684,19 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
protected function _reset_select()
{
$this->_reset_run(array(
- 'qb_select' => array(),
- 'qb_from' => array(),
- 'qb_join' => array(),
- 'qb_where' => array(),
- 'qb_groupby' => array(),
- 'qb_having' => array(),
- 'qb_orderby' => array(),
- 'qb_aliased_tables' => array(),
- 'qb_no_escape' => array(),
- 'qb_distinct' => FALSE,
- 'qb_limit' => FALSE,
- 'qb_offset' => FALSE
- )
- );
+ 'qb_select' => array(),
+ 'qb_from' => array(),
+ 'qb_join' => array(),
+ 'qb_where' => array(),
+ 'qb_groupby' => array(),
+ 'qb_having' => array(),
+ 'qb_orderby' => array(),
+ 'qb_aliased_tables' => array(),
+ 'qb_no_escape' => array(),
+ 'qb_distinct' => FALSE,
+ 'qb_limit' => FALSE,
+ 'qb_offset' => FALSE
+ ));
}
// --------------------------------------------------------------------
@@ -2715,8 +2718,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
'qb_orderby' => array(),
'qb_keys' => array(),
'qb_limit' => FALSE
- )
- );
+ ));
}
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 431016d6a..dc47fd347 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -188,6 +188,7 @@ Release Date: Not Released
- 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``.
+ - Added support for method chaining in query cache methods ``start_cache()``, ``stop_cache()``, ``flush_cache()``.
- :doc:`Database Results <database/results>` changes include: