dadamssg Posted May 24, 2009 Share Posted May 24, 2009 im developing a PM system between users on my forum...my question is: how do i set up a message table and system to have sent messages. right now, i just have it where you can only send messages...and you don't have a sent messages place because when its sent and the user on the receiving end deletes the message its gone from the db....so if i did have a sent messages thing, the person who received it would have the deleting power. how do i set up my table and whats some good theory behind saving a message until both users have 'deleted' it. and then ill run a cron job and check for messages where both users have chose to delete the same message. hope that make sense. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/159452-solved-message-system-setup/ Share on other sites More sharing options...
jackpf Posted May 24, 2009 Share Posted May 24, 2009 Why don't you just have two tables, one for sent messages, one for received? Or, you could have a `Type` field, which will be either "inbox" or "outbox" or whatever. I think it would get a bit complicated attempting it the way you suggested. Quote Link to comment https://forums.phpfreaks.com/topic/159452-solved-message-system-setup/#findComment-841126 Share on other sites More sharing options...
corbin Posted May 24, 2009 Share Posted May 24, 2009 You could just do something like this: CREATE TABLE messages ( message_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, from_id INT NOT NULL, to_id INT NOT NULL, from_deleted BIT DEFAULT 0, to_deleted BIT DEFAULT 0 message_subject VARCHAR(255) DEFAULT '', message_content TEXT ); Then, you would check from_deleted to see whether to show it in the outbox, and you would check to_deleted to see whether to show it in the inbox or not. (You could even have a deleted section by making it a tinyint and doing something like 0: non deleted, 1: trash can, 2: really deleted.) Quote Link to comment https://forums.phpfreaks.com/topic/159452-solved-message-system-setup/#findComment-841247 Share on other sites More sharing options...
dadamssg Posted May 24, 2009 Author Share Posted May 24, 2009 i didn't even think about having two seperate tables! that way, each can have control over their messages and i don't have to run a cron job to delete them...man. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/159452-solved-message-system-setup/#findComment-841351 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.