[pLog-svn] r3013 - plog/trunk/class/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Fri Mar 3 21:16:59 GMT 2006


Author: oscar
Date: 2006-03-03 21:16:58 +0000 (Fri, 03 Mar 2006)
New Revision: 3013

Modified:
   plog/trunk/class/dao/commentscommon.class.php
Log:
finally the counters are all udpated correctly!


Modified: plog/trunk/class/dao/commentscommon.class.php
===================================================================
--- plog/trunk/class/dao/commentscommon.class.php	2006-03-03 20:48:59 UTC (rev 3012)
+++ plog/trunk/class/dao/commentscommon.class.php	2006-03-03 21:16:58 UTC (rev 3013)
@@ -69,19 +69,19 @@
         			$article->setNumComments( $this->getNumItems( $this->getPrefix().'articles_comments', 
         		    	                                          'article_id = '.$article->getId().' AND status = '.COMMENT_STATUS_NONSPAM.
         		        	                                      ' AND type = '.$comment->getType()));
-					$totalComments = $this->getNumItems( $this->getPrefix().'articles_comments', 
-        		    	                                 'article_id = '.$article->getId().' AND type = '.$comment->getType());
-        			$article->setTotalComments( $totalComments );
-        		   	$blog->setTotalComments( $totalComments );
+        			$article->setTotalComments($this->getNumItems( $this->getPrefix().'articles_comments', 
+        		    	                                 'article_id = '.$article->getId().' AND type = '.$comment->getType()));
+					$blog->setTotalComments($this->getNumItems( $this->getPrefix().'articles_comments', 
+					                                            'blog_id = '.$blog->getId().' AND type = '.$comment->getType()));
 				}
 				else {
         			$article->setNumTrackbacks( $this->getNumItems( $this->getPrefix().'articles_comments', 
         		    	                                          'article_id = '.$article->getId().' AND status = '.COMMENT_STATUS_NONSPAM.
         		        	                                      ' AND type = '.$comment->getType()));
-					$totalTrackbacks = $this->getNumItems( $this->getPrefix().'articles_comments', 
-        		    	                                 'article_id = '.$article->getId().' AND type = '.$comment->getType());
-        			$article->setTotalTrackbacks( $totalTrackbacks );
-        		   	$blog->setTotalTrackbacks( $totalTrackbacks );
+        			$article->setTotalTrackbacks($this->getNumItems( $this->getPrefix().'articles_comments', 
+        		    	                                 'article_id = '.$article->getId().' AND type = '.$comment->getType()));
+					$blog->setTotalTrackbacks($this->getNumItems( $this->getPrefix().'articles_comments', 
+					                                              'blog_id = '.$blog->getId().' AND type = '.$comment->getType()));					
 				}
 				$articles = new Articles();
 				$articles->updateArticle( $article );
@@ -267,7 +267,9 @@
 			if( $comment )  {
 				$this->delete( "id", $commentid );
 	            // update all the other posts
-    	        $query = "UPDATE ".$this->getPrefix()."articles_comments SET parent_id = 0 WHERE parent_id = ".$commentid." AND article_id = ".$artid.";";
+    	        $query = "UPDATE ".$this->getPrefix()."articles_comments SET parent_id = 0 WHERE parent_id = '".
+				         Db::qstr($commentid)."' AND article_id = '".
+						 Db::qstr( $comment->getArticleId())."'";
         	    $result = $this->Execute( $query );
         	    $this->_cache->removeData( $comment->getArticleId(), CACHE_ARTICLE_COMMENTS_BYARTICLE );
         	    
@@ -279,18 +281,22 @@
         	    $blog = $article->getBlogInfo();
         	    $type = $comment->getType();
         	    if( $type == COMMENT_TYPE_COMMENT ) {
-	        	    $blog->setTotalComments( $blog->getTotalComments() - 1 );
-	        		$article->setTotalComments( $article->getTotalComments() - 1 );	        	    
-		        	if( $comment->getStatus() == COMMENT_STATUS_NONSPAM ) {
-		        		$article->setNumComments( $article->getNumComments() - 1 );		        		
-		        	}
+        			$article->setNumComments( $this->getNumItems( $this->getPrefix().'articles_comments', 
+        		    	                                          'article_id = '.$article->getId().' AND status = '.COMMENT_STATUS_NONSPAM.
+        		        	                                      ' AND type = '.$comment->getType()));
+        			$article->setTotalComments( $this->getNumItems( $this->getPrefix().'articles_comments', 
+        		    	                                            'article_id = '.$article->getId().' AND type = '.$comment->getType()));
+					$blog->setTotalComments($this->getNumItems( $this->getPrefix().'articles_comments', 
+					                                            'blog_id = '.$blog->getId().' AND type = '.$comment->getType()));
 	        	}
 	        	else {
-	        	    $blog->setTotalTrackbacks( $blog->getTotalTrackbacks() - 1 );	        	
-	        		$article->setTotalTrackbacks( $article->getTotalTrackbacks() - 1 );
-		        	if( $comment->getStatus() == COMMENT_STATUS_NONSPAM ) {
-		        		$article->setNumTrackbacks( $article->getNumTrackbacks() - 1 );		        		
-		        	}
+        			$article->setNumTrackbacks( $this->getNumItems( $this->getPrefix().'articles_comments', 
+        		    	                                          'article_id = '.$article->getId().' AND status = '.COMMENT_STATUS_NONSPAM.
+        		        	                                      ' AND type = '.$comment->getType()));
+        			$article->setTotalTrackbacks($this->getNumItems( $this->getPrefix().'articles_comments', 
+        		    	                                          'article_id = '.$article->getId().' AND type = '.$comment->getType()));
+					$blog->setTotalTrackbacks($this->getNumItems( $this->getPrefix().'articles_comments',
+   					                                              'blog_id = '.$blog->getId().' AND type = '.$comment->getType()));
 	        	}
         	    $blogs = new Blogs();
 	        	$blogs->updateBlog( $blog );
@@ -327,7 +333,6 @@
         		        	                                      ' AND type = '.$comment->getType()));
         			$article->setTotalComments( $this->getNumItems( $this->getPrefix().'articles_comments', 
         		    	                                          'article_id = '.$article->getId().' AND type = '.$comment->getType()));
-        		    
     			}
     			elseif( $comment->getType() == COMMENT_TYPE_TRACKBACK ) {
         			$article->setNumTrackbacks( $this->getNumItems( $this->getPrefix().'articles_comments', 



More information about the pLog-svn mailing list