Dotclear


Ignore:
Timestamp:
05/04/11 13:51:09 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
userprefs
Message:

Fixed handling of comment number updates, closes #1137

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.core.php

    r0 r136  
    14241424     public function countAllComments() 
    14251425     { 
    1426           $strReq = 'SELECT COUNT(comment_id) AS nb, post_id '. 
    1427                     'FROM '.$this->prefix.'comment '. 
    1428                     'WHERE comment_trackback %s 1 '. 
    1429                     'AND comment_status = 1 '. 
    1430                     'GROUP BY post_id '; 
    1431            
    1432           $rsC = $this->con->select(sprintf($strReq,'<>')); 
    1433           $rsT = $this->con->select(sprintf($strReq,'=')); 
    1434            
    1435           $cur = $this->con->openCursor($this->prefix.'post'); 
    1436           while ($rsC->fetch()) { 
    1437                $cur->nb_comment = (integer) $rsC->nb; 
    1438                $cur->update('WHERE post_id = '.(integer) $rsC->post_id); 
    1439                $cur->clean(); 
    1440           } 
    1441            
    1442           while ($rsT->fetch()) { 
    1443                $cur->nb_trackback = (integer) $rsT->nb; 
    1444                $cur->update('WHERE post_id = '.(integer) $rsT->post_id); 
    1445                $cur->clean(); 
    1446           } 
     1426      
     1427          $updCommentReq = 'UPDATE '.$this->prefix.'post P '. 
     1428               'SET nb_comment = ('. 
     1429                    'SELECT COUNT(C.comment_id) from '.$this->prefix.'comment C '. 
     1430                    'WHERE C.post_id = P.post_id AND C.comment_trackback <> 1 '. 
     1431                    'AND C.comment_status = 1 '. 
     1432               ')'; 
     1433          $updTrackbackReq = 'UPDATE '.$this->prefix.'post P '. 
     1434               'SET nb_trackback = ('. 
     1435                    'SELECT COUNT(C.comment_id) from '.$this->prefix.'comment C '. 
     1436                    'WHERE C.post_id = P.post_id AND C.comment_trackback = 1 '. 
     1437                    'AND C.comment_status = 1 '. 
     1438               ')'; 
     1439          $this->con->execute($updCommentReq); 
     1440          $this->con->execute($updTrackbackReq); 
    14471441     } 
    14481442      
Note: See TracChangeset for help on using the changeset viewer.

Sites map