Topic: sql inserts to add posts from an archive file?

I have a flat database file that I can parse in PHP to create a series of "posts" to punbb but I am looking for info on the best way to do this. I have read the punbb database structure docs and understand them but from what I have read so far, I am not really going to insert "posts" but rather "topics" for each entry from my flat database file. My question is .... do I need to add a topic, then a post to the topic and assign the topic to a forum in order to add a new post to the forum directly via a mysql insert?

Thanks

Re: sql inserts to add posts from an archive file?

Hierarchy is forum -> topic -> post.
A forum is a collection of topics, a topic is a collection of posts.
So you can create a forum via PunBB, get its forum ID, and then insert a topic and a post for the topic. You can assign the forum ID to the topic at insertion time.

Re: sql inserts to add posts from an archive file?

Smartys wrote:

Hierarchy is forum -> topic -> post.
A forum is a collection of topics, a topic is a collection of posts.
So you can create a forum via PunBB, get its forum ID, and then insert a topic and a post for the topic. You can assign the forum ID to the topic at insertion time.

Is that all of the relational info thats required for a new post? Just create a topic that belongs to an existing forum id , then create a post to the topic? No other info is required in any other tables for the new topic and/or post?

Re: sql inserts to add posts from an archive file?

Yes.

Re: sql inserts to add posts from an archive file?

Thank you.

Re: sql inserts to add posts from an archive file?

I wanted to do the same thing.
I wrote a script to generate reams of SQL from my flat file.
The basic SQL looks as follows:

Set @forumId = 19;
Set @postingFromIP = '10.0.0.1';
Set @posterName = 'Poster';
Set @posterId = 17;

INSERT INTO punbb_topics (poster, subject, posted, last_post, last_poster, num_views, num_replies, closed, sticky, forum_id) VALUES (@posterName, 'TITLE OF THE POST', UNIX_TIMESTAMP() - 7200, UNIX_TIMESTAMP() - 7200, @posterName, 0, 0, 0, 0, @forumId);
set @topic_id = Last_Insert_ID();
INSERT INTO punbb_posts (poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id) VALUES (@posterName, @posterId, @postingFromIP, 'MESSAGE IN THE POST', 0, UNIX_TIMESTAMP()- 7200, @topic_id);
set @post_id = Last_Insert_ID();
Update punbb_topics set last_post_id = @post_id where id = @topic_id;
set @num_topics = (select num_topics from punbb_forums where id = @forumId);
UPDATE punbb_forums SET num_topics = @num_topics + 1 where id = @forumId;

I haven't done the search SQL, still debating whether it's worth it smile