Skip to:
Content
Pages
Categories
Search
Top
Bottom

importer help please sql

  • @xprojectsx

    Participant

    I’m setting up the importer using the example but I’m a little stuck doing the joins. This is a little advanced for me because it seems to me that I need to join 3 tables and a total of 3 fields to match from the origin forum which has each post separated in two separate tables and those tables reference the forumID in a third table.

    so the example code for topics is:
    `// Setup any table joins needed for the topic section
    $this->field_map[] = array(
    ‘from_tablename’ => ‘replies_table’,
    ‘from_fieldname’ => ‘the_topic_id’,
    ‘join_tablename’ => ‘topics_table’,
    ‘join_type’ => ‘INNER’,
    ‘join_expression’ => ‘USING replies_table.the_topic_id = topics_table.the_topic_id’,
    ‘from_expression’ => ‘WHERE forums_table.the_topic_id = 0’,
    ‘to_type’ => ‘topic’
    );`
    in my source forum tables that are being imported from, it is broken down into four tables:
    forums.forumid, forums.categoryid
    categories.categoryid
    messages.msgid, messages.forumid, messages.threadid, messages.subject
    messagebodies.msgid, messagebodies.forumid, messagebodies.bodytext

    I believe that I can ignore the category to get what is needed but that is still three tables. the threadID is sequential and relative to each forum so there is a thread 1 in forum1 and and thread1 in forum2 and all other forums. So the forum ID has to be referenced in the third table (forums)

    I am thinking this is a “LEFT” with and conditions is that right? can someone get me started with an example? Thank you.

Viewing 1 replies (of 1 total)
  • @xprojectsx

    Participant

    perhaps I over thought this. I tried this below

    $this->field_map[] = array(
    			'from_tablename'  => 'messagebodies',
    			'from_fieldname'  => 'msgid',
    			'join_tablename'  => 'messages',
    			'join_type'       => 'LEFT',
    			'join_expression' => 'USING messagebodies.msgid = messages.msgid AND messagebodies.forumid = messages.forumid',
    			'from_expression' => 'WHERE messages.msgid = 0',
    			'to_type'         => 'topic'

    however I cannot know if this is proper because I am getting an error that seems to point to the base converter logic for “topic” the to_type here of topic should refer to the destination table right?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar