Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP Messages – Database details?


  • CriticalNed
    Participant

    @criticaltodd

    I’m working on a script to migrate a bunch of phpBB private messages to BP’s messaging system. phpBB’s table structure is pretty straightforward, but I’m having trouble figuring out all these squiggly bracket codes in wp_bp_messages_threads, such as the ones below:

    message_ids

    sender_ids

    a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}

    a:2:{i:0;i:1;i:1;s:1:”2″;}

    I get that wp_bp_messages_messages contains the actual message, and that wp_bp_messages_recipients contains the recipient. So wp_bp_messages_threads must be the table that associates these two, right? Can anybody give me advice on how to code my “INSERT INTO” data for the _threads table?? Thanks!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • one thread has one to many messages

    one message has one to many recipients

    one user has zero to many threads

    the squiggly stuff you posted is a serialized array of message and sender ID’s. In PHP if you take that value and use the function unserialize() (or maybe_unserialize() if you are in the WordPress environment) you will get an array full of ID’s you can then iterate and use.


    CriticalNed
    Participant

    @criticaltodd

    Thanks, Andy! I went into the database and observed how these arrays morph as more posts are made. Here’s what I figured out about the serialized array in BP’s wp_bp_messages_threads table:

    First of all, the wp_bp_messages_threads table is indeed the table that associates “messages” table with “recipients” table.

    In the message_ids column:

    a:4:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:5;}

    – a:4 means there are 4 messages in the thread

    – the i’s are the links between messages in the thread. There are 4 messages in the thread, and the thread IDs are 1, 2, 3, and 5. I’m not sure why we start with i:0 to i:1, but after that the connections are i:1 to i:2, i:2 to i:3, and i:3 to i:5.

    In the sender_ids column:

    a:2:{i:0;i:1;i:1;s:1:”2″;}

    – I guess a:2 means that the sender has 2 messages in the thread, but I don’t know why that information is useful yet. I don’t know what the i’s mean in this context. I don’t know what s means. “2” is the user_id of the sender.

    I was able to put this together and come up with a simple import script that turns phpBB message data into BP messages. It’s just a “flat” import, by which I mean that the script does not use the BP threading functionality; it just gives every message a simple “message_ids” table entry, such as a:1:{i:0;i:55;} where 55 is the id of the message, and a simple “sender_ids” entry, such as a:1:{i:0;i:3;}, where 3 is the id of the user in wp_users.

    Is somebody putting all this in the codex? I don’t feel I’m qualified enough to enter these snippets, but hopefully this type of documentation will be emerging soon.


    CriticalNed
    Participant

    @criticaltodd

    well, this import went so-so. The messages are there, but the pagination of messages is “off”. Page one has 7 messages, while page 2 has only 6 messages. Pages 3 and 4 have only 4 messages, and when I click on page 5, it says “you have no messages in your inbox.” I guess that’s what hacking gets you.

    Anybody have ideas on what to do next?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘BP Messages – Database details?’ is closed to new replies.
Skip to toolbar