XPressME Integration Kit

Trac


Ignore:
Timestamp:
Dec 7, 2009, 9:35:09 AM (15 years ago)
Author:
toemon
Message:

閲覧数表示がリセットされるバグ修正 Fixes #265

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/include/onupdate.php

    r474 r481  
    221221                        $db->queryF( $queries ) ; 
    222222                        $msgs[] = "$views_table  ADD blog_id ."; 
     223                } 
     224                 
     225                // The table is repaired. 
     226                $non_blogid_sql ="SELECT * FROM $views_table WHERE blog_id IS NULL OR blog_id < 1"; 
     227                $non_blogid_res = $db->query($non_blogid_sql, 0, 0); 
     228                while($row = $db->fetchArray($non_blogid_res)){ 
     229                        $total_view = $row['post_views']; 
     230                        $post_id = $row['post_id']; 
     231                        $new_blogid_sql ="SELECT SUM(post_views) as post_views_sum FROM $views_table WHERE post_id = $post_id AND blog_id = 1 GROUP BY post_id"; 
     232                        $new_blogid_res = $db->query($new_blogid_sql, 0, 0); 
     233                        if ($db->getRowsNum($new_blogid_res)  > 0){ 
     234                                $new_row = $db->fetchArray($new_blogid_res); 
     235                                $total_view = $total_view + $new_row['post_views_sum']; 
     236                                $del_sql = "DELETE FROM $views_table WHERE post_id = $post_id AND blog_id = 1"; 
     237                                $db->queryF( $del_sql ) ; 
     238                        } 
     239                        $update_sql = "UPDATE $views_table SET post_views = $total_view , blog_id = 1 WHERE post_id = $post_id AND (blog_id IS NULL OR blog_id < 1)"; 
     240                        $db->queryF( $update_sql ) ; 
    223241                } 
    224242        } 
Note: See TracChangeset for help on using the changeset viewer.