Andrey_Wlodimirovich
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Код: # #-----[ OPEN ]------------------------------------------ # modcp.php # #-----[ FIND ]------------------------------------------ # $sql = "SELECT poster_id, COUNT(post_id) AS posts FROM " . POSTS_TABLE . " WHERE topic_id IN ($topic_id_sql) GROUP BY poster_id"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql); } $count_sql = array(); while ( $row = $db->sql_fetchrow($result) ) { $count_sql[] = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts - " . $row['posts'] . " WHERE user_id = " . $row['poster_id']; } $db->sql_freeresult($result); if ( sizeof($count_sql) ) { for($i = 0; $i < sizeof($count_sql); $i++) { if ( !$db->sql_query($count_sql[$i]) ) { message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql); } } } # #-----[ REPLACE WITH ]------------------------------------------ # $sql = "SELECT forum_postcount FROM " . FORUMS_TABLE . " WHERE forum_id = $forum_id"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get topic id information', '', __LINE__, __FILE__, $sql); } $forum_postcount = 1; while ($row = $db->sql_fetchrow($result)) { $forum_postcount = $row['forum_postcount']; } $db->sql_freeresult($result); if ($forum_postcount){ $sql = "SELECT poster_id, COUNT(post_id) AS posts FROM " . POSTS_TABLE . " WHERE topic_id IN ($topic_id_sql) GROUP BY poster_id"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql); } $count_sql = array(); while ( $row = $db->sql_fetchrow($result) ) { $count_sql[] = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts - " . $row['posts'] . " WHERE user_id = " . $row['poster_id']; } $db->sql_freeresult($result); if ( sizeof($count_sql) ) { for($i = 0; $i < sizeof($count_sql); $i++) { if ( !$db->sql_query($count_sql[$i]) ) { message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql); } } } } # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM |
|