cmgmyr Posted August 1, 2007 Share Posted August 1, 2007 I have a private messaging system on my site right now thats pretty simple and gets the job done. But I want to make it better and more efficient. Right now I have: CREATE TABLE `mail` ( `mid` int(11) NOT NULL auto_increment, `uidto` int(11) NOT NULL default '0', `uidfrom` int(11) NOT NULL default '0', `subject` text NOT NULL, `message` text NOT NULL, `status` tinyint(1) NOT NULL default '0', `status2` tinyint(1) NOT NULL default '0', `date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`mid`) ) ENGINE=MyISAM ; for the database. What I'm doing is if you reply to a message it puts the last message below it and you type your new message on top This is my reply -------------- This is this original so as you can imaging after a few messages back and fourth the body of the message gets pretty big. What I want to do is set it up kind of like Facebook. Having parent_id's for messages and having a recursive function flip through them all in a "conversation" instead of having the whole conversation in one DB entry. What do you think about doing this the new way with the recursive function? Do you forsee any problems with this? Any other ideas that you would like to pass along? Thanks, -Chris Quote Link to comment Share on other sites More sharing options...
448191 Posted August 3, 2007 Share Posted August 3, 2007 This tut should help: http://www.sitepoint.com/article/hierarchical-data-database Some discussion of modified preorder tree traversal and hierarchical-relational issues on the boards: http://www.phpfreaks.com/forums/index.php/topic,142307.0.html http://www.phpfreaks.com/forums/index.php/topic,123697.15.html Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted August 3, 2007 Author Share Posted August 3, 2007 Cool, thanks for those. I actually went ahead and made this new messaging system. It works really well. It's a lot better then the older version that I mentioned. I already got good feedback from the upgrade Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 3, 2007 Share Posted August 3, 2007 while not trying to make a PM system, i really liked that article about the modified preorder tree traversal design. so much more efficient than query recursion, and it doesn't actually take THAT much to wrap your head around it. guaranteed to make its way into my future hierarchical applications. thanks 448191. Quote Link to comment 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.