From ddf83e4db6a08b7b1ef7e9b53c9c43808b0ccb36 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 24 Sep 2006 20:25:42 +0000 Subject: --- user_guide/database/results.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'user_guide/database') 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(); +

$query->free_result()

+

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: +

+ +$query = $this->db->query('SELECT title FROM my_table');

+foreach ($query->result() as $row)
+{
+   echo $row->title;
+}
+$query->free_result(); // The $query result object will no longer be available
+
+$query2 = $this->db->query('SELECT name FROM some_table');

+$row = $query2->row();
+echo $row->name;
+$query2->free_result(); // The $query2 result object will no longer be available +
+ + + -- cgit v1.2.3-24-g4f1b