summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-24 22:25:42 +0200
committeradmin <devnull@localhost>2006-09-24 22:25:42 +0200
commitddf83e4db6a08b7b1ef7e9b53c9c43808b0ccb36 (patch)
tree2f5d379115f6841b0b42c23f90cfe83aa0d24482
parent1716d5880b5b8d26db5608922f88adcf1ff8077c (diff)
-rw-r--r--user_guide/database/results.html21
1 files changed, 21 insertions, 0 deletions
diff --git a/user_guide/database/results.html b/user_guide/database/results.html
index 8e8d3cf96..bea00caea 100644
--- a/user_guide/database/results.html
+++ b/user_guide/database/results.html
@@ -203,6 +203,27 @@ echo $query->num_fields();
+<h2>$query->free_result()</h2>
+<p>It frees the memory associated with the result and deletes the result resource ID. Normally PHP frees its memory automatically at the end of script
+execution. However, if you are running a lot of queries in a particular script you might want to free the result after each query result has been
+generated in order to cut down on memory consumptions. Example:
+</p>
+
+<code>$query = $this->db->query('SELECT title FROM my_table');<br /><br />
+foreach ($query->result() as $row)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;echo $row->title;<br />
+}<br />
+$query->free_result(); // The $query result object will no longer be available<br />
+<br />
+$query2 = $this->db->query('SELECT name FROM some_table');<br /><br />
+$row = $query2->row();<br />
+echo $row->name;<br />
+$query2->free_result(); // The $query2 result object will no longer be available
+</code>
+
+
+
</div>