Jump to content

Recommended Posts

How does phpBB create ID's for its topics?

 

eg: www.phpfreaks.com/forums/index.php?topic=335536.0

 

How is 'topic=335536.0' generated? (i'm guessing the '.0' is the value used to determine the page number)

 

The post ID is simple a AI field I'm guessing, but then each post needs to link to a topic ID which is in the same table and thus cannot be an auto Increment as there needs to multiple entries using the same topic ID...

 

My initial thoughts:

 

Count the DISTINCT topic ID's then +1 for the new one (But what if 1000 people all simultaneously press 'post' at the same time? Would the DISTINCT count therefore be incorrect for some?)

or//

Taking the OP's ID and coupling with the current unix timestamp (this one will only work if a user can only ever be logged into a system once at any one time)

 

 

(probably miles off here, but i'm creating a system with a similar concept to topic ID's and kinda stuck as to the best way)

Link to comment
https://forums.phpfreaks.com/topic/238879-best-way-to-determine-a-topic-id/
Share on other sites

Simple, for existing ones posts: the parent ID of the topic is located in the same (or table joining the two) row. Every post belongs to a topic.

ID | Topic ID | Post info
1    335536        ...

 

When creating a new topic, there is a topic table, with some data about the topics, and then an AI ID kicks in.

 

Try installing a forum and see for yourself :)

ahhhh... I see. Well that makes sense  ::)

 

So when a new topic is created, the first step is to create a new entry in the 'topic table' which has its own AI ID field. After inserting this, the topics ID just right there...

 

Thank you. Can't believe I didn't click on that.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.