forum_id in posts table

Discuss general development subjects that are not specific to a particular version like the versioning control system we use or other infrastructure.
Post Reply
v12mike
Registered User
Posts: 14
Joined: Wed Dec 07, 2016 10:05 pm

forum_id in posts table

Post by v12mike »

The phpBB database has a forum_id field in the posts table as well as a forum_id field in the topics table. I would like clarification as to whether this is an intended part of the design, or just an historical artefact?
Is there any intended scenario where the post and its topic will have different forum_ids?

User avatar
rxu
Registered User
Posts: 131
Joined: Tue Apr 04, 2006 4:28 pm
Contact:

Re: forum_id in posts table

Post by rxu »

Post and its topic always have the same parent forum_id.
I guess that was made to make related SQL queries lighter.
Image

warmweer
Registered User
Posts: 109
Joined: Wed Jul 09, 2003 5:27 pm
Location: Belgium

Re: forum_id in posts table

Post by warmweer »

Isn't it because a shadow topic could reside in a different forum?
Procrastination is my hobby, but I keep on postponing it.

v12mike
Registered User
Posts: 14
Joined: Wed Dec 07, 2016 10:05 pm

Re: forum_id in posts table

Post by v12mike »

So is it more precise to say that post.forum_id is the forum where the post was originally made and topic.forum_id is the forum where the post currently resides?

I have always used topic.forum_id, but I think that here are a few places in extensions (and even core code) that assume that post.forum_id is the current forum.

User avatar
rxu
Registered User
Posts: 131
Joined: Tue Apr 04, 2006 4:28 pm
Contact:

Re: forum_id in posts table

Post by rxu »

Nope. post.forum_id and its topic.forum_id are identical. When the post's parent topic get moved to another forum, the posts's forum_ig get updated.
Image

Post Reply