freelance84 Posted June 9, 2011 Share Posted June 9, 2011 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) Quote Link to comment https://forums.phpfreaks.com/topic/238879-best-way-to-determine-a-topic-id/ Share on other sites More sharing options...
Philip Posted June 9, 2011 Share Posted June 9, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/238879-best-way-to-determine-a-topic-id/#findComment-1227543 Share on other sites More sharing options...
freelance84 Posted June 9, 2011 Author Share Posted June 9, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/238879-best-way-to-determine-a-topic-id/#findComment-1227567 Share on other sites More sharing options...
.josh Posted June 9, 2011 Share Posted June 9, 2011 FYI we use SMF not phpbb. Quote Link to comment https://forums.phpfreaks.com/topic/238879-best-way-to-determine-a-topic-id/#findComment-1227593 Share on other sites More sharing options...
freelance84 Posted June 9, 2011 Author Share Posted June 9, 2011 cool. (just been playing Portal2. Setting the topic ID feels likes a stage of that game haha) Quote Link to comment https://forums.phpfreaks.com/topic/238879-best-way-to-determine-a-topic-id/#findComment-1227698 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.