importer help please sql
-
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.bodytextI 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.
- You must be logged in to reply to this topic.