liamloveslearning Posted May 23, 2008 Share Posted May 23, 2008 Im jsut wondering; in a messaging system, if a user wanted to save a message and store it in there saved messages, would I be required to produce a table for saved data? or would it call data from the initial table of messages? my only cause for concern is that if i do use 1 table of data and echo it on the saved page; if the user who sent the message deletes it; essentially wont that dissapear from the "saved msgs" page as its no longer in the table? ??? Link to comment https://forums.phpfreaks.com/topic/106998-save-messages/ Share on other sites More sharing options...
BlueSkyIS Posted May 23, 2008 Share Posted May 23, 2008 i would use 1 table and have a field called message_status, using a small integer to indicate the status of the message, then only display that message where it should be displayed based on the value of message_status. Link to comment https://forums.phpfreaks.com/topic/106998-save-messages/#findComment-548448 Share on other sites More sharing options...
jonsjava Posted May 23, 2008 Share Posted May 23, 2008 create 2 fields in the table. one named "sender_has" and one named "receiver_has". set both to not null default value=1 if the sender deletes it, just set their value to 0, and the same for receiver. if they are both set to "0", then delete it from the db. Link to comment https://forums.phpfreaks.com/topic/106998-save-messages/#findComment-548450 Share on other sites More sharing options...
liamloveslearning Posted May 23, 2008 Author Share Posted May 23, 2008 ahh okay thanks; ill give it a go now Link to comment https://forums.phpfreaks.com/topic/106998-save-messages/#findComment-548456 Share on other sites More sharing options...
liamloveslearning Posted May 23, 2008 Author Share Posted May 23, 2008 sorry can i just ask, how would i automatically have it deleted from the db when both field values = 0? Link to comment https://forums.phpfreaks.com/topic/106998-save-messages/#findComment-548462 Share on other sites More sharing options...
liamloveslearning Posted May 23, 2008 Author Share Posted May 23, 2008 in regards to blueskyis, even if i displayed the row of data coinciding with a message_status, that doesnt prevent the other user from deleting the message does it? Link to comment https://forums.phpfreaks.com/topic/106998-save-messages/#findComment-548481 Share on other sites More sharing options...
BlueSkyIS Posted May 23, 2008 Share Posted May 23, 2008 for each user, i would tie their user_id to any messages that they have individually via a join table consisting of the columns: id, user_id, message_id, status. when the user deletes the message, they just delete the join record, not the message itself. Link to comment https://forums.phpfreaks.com/topic/106998-save-messages/#findComment-548496 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.