1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Posting a thread

Discussion in 'XenForo Development Discussions' started by evilmaniac, Mar 15, 2013.

  1. evilmaniac

    evilmaniac Member

    I currently run a few game servers and wanted to implemented a feature where players can report rule-breakers in game through a simple command. The command would create a thread in a certain node on the forum so that admins can see it. I intended to do this by directly adding the post to the `xf_post` table but was wondering about the other values I need to amend on the database (such as post counts for the user that made the post etc).
     
  2. Kent

    Kent Active Member

    Only updating xf_thread and xf_post seems to work fine, but I'm not sure how much of it is absolutely required or will cause problem if not properly updated.
    Considering even a thread with no posts works without apparent error, I think XF handles missing data quite well.

    Queries run by XenForo when making a new thread:
    Code:
    INSERT INTO `xf_thread` (`user_id`, `username`, `title`, `prefix_id`, `node_id`, `discussion_state`, `discussion_open`, `sticky`, `post_date`, `last_post_date`, `last_post_user_id`, `last_post_username`, `reply_count`, `view_count`, `discussion_type`, `first_post_id`, `last_post_id`, `first_post_likes`)
    VALUES ('1', 'Admin', 'This is a new thread.', '0', '8', 'visible', '1', '0', '1363371963', '1363371963', '1', 'Admin', '0', '0', '', '0', '0', '0')
     
    INSERT INTO `xf_post` (`message`, `thread_id`, `user_id`, `username`, `post_date`, `message_state`, `position`, `ip_id`, `attach_count`, `likes`, `like_users`, `warning_id`, `warning_message`)
    VALUES ('This is a new message in a new thread.', '9', '1', 'Admin', '1363371963', 'visible', '0', '0', '0', '0', 'a:0:{}', '0', '')
     
    INSERT INTO `xf_ip` (`user_id`, `content_type`, `content_id`, `action`, `ip`, `log_date`) VALUES ('1', 'post', '25', 'insert', '3232236135', '1363371963')
    UPDATE `xf_post` SET `ip_id` = '66' WHERE (post_id = 25)
     
    UPDATE `xf_attachment` SET `content_type` = 'post', `content_id` = '25', `temp_hash` = '', `unassociated` = '0' WHERE (temp_hash = '0c4d927fb0fed30f1d26a1e88f5ea228')
     
    UPDATE xf_user
    SET message_count = message_count + 1
    WHERE user_id = '1'
     
    REPLACE DELAYED INTO xf_search_index
    (content_type, content_id,
    title, message, metadata,
    item_date, user_id, discussion_id)
    VALUES
    ('post', 25, 'This is a new thread.', 'This is a new message in a new thread.', '_md_user_1 _md_content_post _md_node_8 _md_thread_9', 1363371963, 1, 9)
     
    UPDATE `xf_thread` SET `first_post_id` = '25', `last_post_id` = '25' WHERE (thread_id = 9)
     
    INSERT INTO `xf_news_feed` (`user_id`, `username`, `content_type`, `content_id`, `action`, `extra_data`, `event_date`) VALUES ('1', 'Admin', 'thread', '9', 'insert', '', '1363371963')
     
    UPDATE `xf_forum` SET `discussion_count` = '3', `message_count` = '4', `last_post_date` = '1363371963', `last_post_id` = '25', `last_thread_title` = 'This is a new thread.' WHERE (node_id = 8)
     
    REPLACE DELAYED INTO xf_search_index
    (content_type, content_id,
    title, message, metadata,
    item_date, user_id, discussion_id)
    VALUES
    ('thread', 9, 'This is a new thread.', '', '_md_user_1 _md_content_thread _md_node_8 _md_thread_9', 1363371963, 1, 9)
     
  3. tyteen4a03

    tyteen4a03 Well-Known Member

    That is... a lot.
     
  4. evilmaniac

    evilmaniac Member

    Thank you for reply :) this will be useful :D
     

Share This Page