[pLog-svn] r1755 - plog/branches/plog-1.1-ben/class/dao

ork at devel.plogworld.net ork at devel.plogworld.net
Tue Apr 5 19:43:24 GMT 2005


Author: ork
Date: 2005-04-05 19:43:24 +0000 (Tue, 05 Apr 2005)
New Revision: 1755

Modified:
   plog/branches/plog-1.1-ben/class/dao/articles.class.php
Log:
added cache for article_text


Modified: plog/branches/plog-1.1-ben/class/dao/articles.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/dao/articles.class.php	2005-04-05 19:37:38 UTC (rev 1754)
+++ plog/branches/plog-1.1-ben/class/dao/articles.class.php	2005-04-05 19:43:24 UTC (rev 1755)
@@ -105,7 +105,7 @@
 				$query .= " AND a.user_id = ".Db::qstr($userId);
 			if( $categoryId != -1 )
 				$query .= " AND c.id = ".Db::qstr($categoryId)." AND c.id = l.category_id AND a.id = l.article_id";
-			if( $status != null ) {
+			if( $status != null && $status != POST_STATUS_PUBLISHED ) {
 				$query .= " AND a.status = $status;";
             }
 
@@ -705,16 +705,24 @@
 		 */
 		function getArticleText( $articleId )
 		{
-			$prefix = $this->getPrefix();
-			$query = "SELECT * FROM {$prefix}articles_text
-			          WHERE article_id = '".Db::qstr($articleId)."'";
-					  
-			$result = $this->Execute( $query );
-			
-			if( !$result ) 
-				return false;
-				
-			return( $result->FetchRow());
+            $text = $this->_cache->getData( $articleId, CACHE_ARTICLETEXT );
+
+            if( !$text ) {
+                $prefix = $this->getPrefix();
+                $query = "SELECT * FROM {$prefix}articles_text
+                          WHERE article_id = '".Db::qstr($articleId)."'";
+
+                $result = $this->Execute( $query );
+                
+                if( !$result ) 
+                    return false;
+                    
+                $text = $result->FetchRow();
+
+                $this->_cache->setData( $articleId, CACHE_ARTICLETEXT, $text );
+            }
+
+            return $text;
 		}
 		
 		/**
@@ -733,6 +741,8 @@
                      ", normalized_topic = '".$filter->normalizeText(Db::qstr($article->getTopic()))."'".
                      " WHERE article_id = ".$article->getId().";";
 			
+            $this->_cache->removeData( $article->getId(), CACHE_ARTICLETEXT );
+
 			return($this->Execute( $query ));
 		}
 




More information about the pLog-svn mailing list