1

Topic: Deleted post in database caused problem

Hello.

I had some problems with spam on my forum. Because of the integration I have done on my site I had to delete the posts directly in  the database. The problem I have now is that the total number of posts in my forum is not correct since in the table "forums" "num_topics" and "num_posts" includes the spamposts I removed. Is there any way to recalculate the numbers of posts in my forum and update the table "forums" with the correct numbers?

Any help is appreciated
Erik

Re: Deleted post in database caused problem

This worked for me:

UPDATE pun_forums AS f SET num_posts=(SELECT SUM(num_replies) FROM pun_topics WHERE forum_id=f.id)+(SELECT count(id) FROM pun_topics WHERE forum_id=f.id)

Replace the 'pun_' prefix with your tables' prefix.

It'll work as long as the forums have 1 or more topics.

3

Re: Deleted post in database caused problem

Thank you garciat. I will try it out and tell you how it worked for me.

Peppe