Jump to content

Storing Multiple Message in Database


upp

Recommended Posts

I need some advice, I'm not sure if this is the right section to post this or not but I'll give it a try. I am creating a website for a small group of people to be able to message back and forth. I ran into a problem when doing the whole reply to a message option. I dont want to have each individual message as a new entry in my database, and then look for each message in that conversation when loading the conversation, I thought about inserting something like +=+=+=+=+=+= in between messages in the conversation so that when i pull up that conversation i could just separate the messages into an array by looking for that +=+=+=+=+=+= in the string of text and separating all the messages out. I want to know if anyone knows a better way of doing this or if this is a good way to go. thanks for any suggestions.

Link to comment
Share on other sites

I have to agree with Pikachu on this, keep each msg seperate, add a replythread to field  and a loop which gets the the previous messages.
Pretty simple
pseudo code.

$replythread=$msg['replythread)

while(!empty($msg['replythread'])

{

    $next_msg=get_msg($replythread);

    if(!empty($next_msg))

    {

      $msg['body'].="+++++\n".$next_msg['body'];

      $replythread=$next_msg['replythread'];

  } else

      $replythread=0;

}

[/code]

 

another option is to store all the ids into replythread (as a string)

About the only bad thing of this method is that the field should be large enough to hold a very long list of ids.

 

pseudo code.

[/code]

$replythread=explode(',',$msg['replythread'])

foreach($replythread as $thread)

{

    $next_msg=get_msg($thread);

    $msg['body'].="+++++\n".$next_msg['body'];

    $replythread=$next_msg['replythread'];

}

[/code]

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.