proggR Posted October 31, 2009 Share Posted October 31, 2009 I'm working on scripts for an imageboard/forum and just realized I don't know how to reorganize the table based on the most recent update. I have a thread table and a reply table and I want to write the script so when a reply is made the coresponding thread gets moved to the bottom of the thread table. And it also doesn't change the Id which is the primary key and autoincremented. I was thinking about making another table that would keep track of the order and just reference the thread list and constantly delete/insert columns to make them in order. That seems inefficient to me, especially if you look at popular forums and imageboards that have replies and new threads flying in by the hundreds per minute. If anyone knows anything that could help I'd really appreciate it. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/179745-keeping-data-organized-by-updates-aka-bump/ Share on other sites More sharing options...
Mchl Posted October 31, 2009 Share Posted October 31, 2009 Just order it by timestamp of last reply? Quote Link to comment https://forums.phpfreaks.com/topic/179745-keeping-data-organized-by-updates-aka-bump/#findComment-948354 Share on other sites More sharing options...
proggR Posted October 31, 2009 Author Share Posted October 31, 2009 How do I change the order though? Would I change the order in the tables or write a script to figure out the order to display everything? I think that'd be slower because I'd have to query the reply table, figure out the x most recent threads that were replied to, then query the thread table for those threads, and repeat for each page of posts. I'm sure I'm just thinking about it the wrong way. I would probably need to join the two or something in one query. Quote Link to comment https://forums.phpfreaks.com/topic/179745-keeping-data-organized-by-updates-aka-bump/#findComment-948372 Share on other sites More sharing options...
Mchl Posted October 31, 2009 Share Posted October 31, 2009 I would probably need to join the two or something in one query. Yup. Moving data around to keep it ordered is not so good an idea. Instead try to write a smart query. As far as I know, every other forum software does it this way Quote Link to comment https://forums.phpfreaks.com/topic/179745-keeping-data-organized-by-updates-aka-bump/#findComment-948375 Share on other sites More sharing options...
fenway Posted November 14, 2009 Share Posted November 14, 2009 Yes, don't mess around with the underlying data.... feel free to make summary tables, though. Quote Link to comment https://forums.phpfreaks.com/topic/179745-keeping-data-organized-by-updates-aka-bump/#findComment-957419 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.