From d9f73db2b4e234bd10499ac060996ece3713d74b Mon Sep 17 00:00:00 2001 From: Rick Ellis Date: Sat, 18 Oct 2008 06:40:04 +0000 Subject: --- user_guide/database/active_record.html | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 77a168fdb..2a8955c4d 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -698,34 +698,45 @@ $query = $this->db->get();

 

 Active Record Caching

-

While not "true" caching, Active Record enables you to save (or "cache") certain parts of your queries for reuse later. Normally, when an Active Record call is completed, all stored information is reset for the next call. With caching, you can prevent this reset, and reuse information easily.

+ +

While not "true" caching, Active Record enables you to save (or "cache") certain parts of your queries for reuse at a later point in your script's execution. Normally, when an Active Record call is completed, all stored information is reset for the next call. With caching, you can prevent this reset, and reuse information easily.

+

Cached calls are cumulative. If you make 2 cached select() calls, and then 2 uncached select() calls, this will result in 4 select() calls. There are three Caching functions available:

+

$this->db->start_cache()

+

This function must be called to begin caching. All Active Record queries of the correct type (see below for supported queries) are stored for later use.

+

$this->db->stop_cache()

+

This function can be called to stop caching.

+

$this->db->flush_cache()

+

This function deletes all items from the Active Record cache.

+

Here's a usage example:

+

$this->db->start_cache();
$this->db->select('field1');
-$this->db->stop_cache();
+$this->db->stop_cache();

$this->db->get('tablename');
-// Results in:
-// SELECT `field1` FROM (`tablename`)
+
+//Generates: SELECT `field1` FROM (`tablename`)

$this->db->select('field2');
$this->db->get('tablename');
-// Results in:
-// SELECT `field1`, `field2` FROM (`tablename`)
+
+//Generates: SELECT `field1`, `field2` FROM (`tablename`)

$this->db->flush_cache();

$this->db->select('field2');
$this->db->get('tablename');
-// Results in:
-// SELECT `field2` FROM (`tablename`)

-

Note: The following fields can be cached: ‘select’, ‘from’, ‘join’, ‘where’, ‘like’, ‘groupby’, ‘having’, ‘orderby’, ‘set’

+
+//Generates: SELECT `field2` FROM (`tablename`)

+ +

Note: The following statements can be cached: select, from, join, where, like, groupby, having, orderby, set

 

-- cgit v1.2.3-24-g4f1b