4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 24, 2018, 08:12:45 PM

Login with username, password and session length
Search:     Advanced search
4images is now on facebook. Click here and become a fan!
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Help / Hilfe
| |-+  Bug Fixes & Patches
| | |-+  [1.7 - 1.7.6] Comments count not updated after user was deleted.
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: [1.7 - 1.7.6] Comments count not updated after user was deleted.  (Read 13050 times)
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 576

mmm PHP...


View Profile WWW
« on: September 01, 2008, 02:12:24 AM »

When a user deleted with their comments, the comments count in each image not being updated.

In admin/users.php find:

1
    if ($delcomments) {

Insert BELOW:

1
2
3
4
5
6
7
8
9
10
11
12
13
      $sql "SELECT i.image_id, COUNT(c.comment_id) AS count
              FROM " 
IMAGES_TABLE " i
              LEFT JOIN " 
COMMENTS_TABLE " c ON c.image_id = i.image_id
              WHERE c.user_id = " 
$user_id "
              GROUP BY i.image_id"
;
      
$result $site_db->query($sql);
      while(
$row $site_db->fetch_array($result))
      {
        
$sql "UPDATE " IMAGES_TABLE "
                SET image_comments = image_comments - " 
$row['count'] ."
                WHERE image_id = " 
$row['image_id'];
        
$site_db->query($sql);
      }


If your comments count not messed up you don't need do anything else, but for these who's comments count different from actual count you can run this MySQL query in phpmyadmin:
1
2
UPDATE 4images_images i
SET i.image_comments = (SELECT COUNT(comment_id) FROM 4images_comments WHERE image_id = i.image_id)

If the query above didn't work for you, download attached file, extract update_comments_count.php from the package and upload it to your 4images root directory then run it by typing in your browser: http://yoursiteaddress/4images/update_comments_count.php
After that delete the file.

* update_comments_count.zip (0.44 KB - downloaded 115 times.)
« Last Edit: February 18, 2009, 08:39:17 AM by V@no » Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.079 seconds with 19 queries.
Post your comments here