From 930d05220955ef46780a0a868e21224c2f724fd2 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 5 Oct 2006 05:28:07 +0000 Subject: --- user_guide/database/caching.html | 43 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'user_guide') diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html index 0f852cf03..1ee0b19b8 100644 --- a/user_guide/database/caching.html +++ b/user_guide/database/caching.html @@ -112,23 +112,32 @@ single answer to the question of whether you should cache your database. It rea are not. -$this->db->cache_on(); // Turns on caching. We assume that you've set up a valid cache foler... - -$query = $this->db->query("SELECT * FROM blog LIMIT 10); - -foreach ($query->result() as $row) -{ - echo '

'.$row->title.'

'; - echo '

'>.$row->content.'

'; -} - - - - - - - - +// Turn OFF caching for this one query since we don't
+// want it to affect any existing cache files
+$this->db->cache_off();
+
+$this->db->query("UPDATE web_stats SET page_views = page_views + 1");
+

+ +// Re-enable caching
+$this->db->cache_on();
+
+$query = $this->db->query("SELECT * FROM blog LIMIT 10");
+
+foreach ($query->result() as $row)
+{
+ echo '<h3>'.$row->title.'</h3>';
+ echo '<p>'>.$row->content.'</p>';
+}
+
+$query = $this->db->query("SELECT page_views FROM web_stats");
+$row = $query->row();
+
+echo '<p>'.$row->page_views.'</p>';
+
+// Update the web stats, so we turn off caching so that the cache
+// file for the above query doesn't get deleted
+
-- cgit v1.2.3-24-g4f1b