summaryrefslogtreecommitdiffstats
path: root/user_guide/database
diff options
context:
space:
mode:
authorRick Ellis <rick.ellis@ellislab.com>2008-10-18 08:40:04 +0200
committerRick Ellis <rick.ellis@ellislab.com>2008-10-18 08:40:04 +0200
commitd9f73db2b4e234bd10499ac060996ece3713d74b (patch)
treed4220a2c8e13811ac3ee3183d0951a2915ec232c /user_guide/database
parent65837c7d6fe0e89b93b102382da264ef8830ca32 (diff)
Diffstat (limited to 'user_guide/database')
-rw-r--r--user_guide/database/active_record.html29
1 files 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();</code>
<p>&nbsp;</p>
<h1><a name="caching">&nbsp;</a>Active Record Caching</h1>
-<p>While not &quot;true&quot; caching, Active Record enables you to save (or &quot;cache&quot;) 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.</p>
+
+<p>While not &quot;true&quot; caching, Active Record enables you to save (or &quot;cache&quot;) 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.</p>
+
<p>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:</p>
+
<h2>$this-&gt;db-&gt;start_cache()</h2>
+
<p>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.</p>
+
<h2>$this-&gt;db-&gt;stop_cache()</h2>
+
<p>This function can be called to stop caching.</p>
+
<h2>$this-&gt;db-&gt;flush_cache()</h2>
+
<p>This function deletes all items from the Active Record cache.</p>
+
<p>Here's a usage example:</p>
+
<p><code>$this-&gt;db-&gt;start_cache();<br />
$this-&gt;db-&gt;select('field1');<br />
-$this-&gt;db-&gt;stop_cache();<br />
+$this-&gt;db-&gt;stop_cache();<br /><br />
$this-&gt;db-&gt;get('tablename');<br />
-// Results in:<br />
-// SELECT `field1` FROM (`tablename`)<br />
+<br />
+//Generates: SELECT `field1` FROM (`tablename`)<br />
<br />
$this-&gt;db-&gt;select('field2');<br />
$this-&gt;db-&gt;get('tablename');<br />
-// Results in:<br />
-// SELECT `field1`, `field2` FROM (`tablename`)<br />
+<br />
+//Generates: SELECT `field1`, `field2` FROM (`tablename`)<br />
<br />
$this-&gt;db-&gt;flush_cache();<br />
<br />
$this-&gt;db-&gt;select('field2');<br />
$this-&gt;db-&gt;get('tablename');<br />
-// Results in:<br />
-// SELECT `field2` FROM (`tablename`)</code></p>
-<p class="important"> <strong>Note:</strong> The following fields can be cached: ‘select’, ‘from’, ‘join’, ‘where’, ‘like’, ‘groupby’, ‘having’, ‘orderby’, ‘set’</p>
+<br />
+//Generates: SELECT `field2` FROM (`tablename`)</code></p>
+
+<p class="important"> <strong>Note:</strong> The following statements can be cached: select, from, join, where, like, groupby, having, orderby, set</p>
<p>&nbsp;</p>
</div>
<!-- END CONTENT -->