No announcement yet.

Adding a thread manually

  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding a thread manually

    I've been searching for information on this for a long time, but to no avail.

    I am trying to understand how to manually add a new thread via the DB and have it show up in the forums. However, when I create the record in the thread and post tables, the thread does not show up.

    I'm trying to make an events forum so that people cannot add new threads, but rather, threads are created by an application that I am writing.

    Any help, or even just a point in the right direction, would be awesome. Again, I'm trying to do this only by using raw mysql queries.... if possible.


  • #2
    you cant put it into the db with something like phpmyadmin
    thats more complex...
    so use the datamanager
    PHP Code:
            require_once(DIR '/includes/functions_databuild.php'); /* included to build new thread and update counters */ 
    $threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
    $threadinfo = array();



    $threadid $threaddm->save();



    • #3
      Awesome. Just what I'm looking for.

      The $threadinfo variable is to remain an empty array?

      What should the $foruminfo variale contain?

      $pagetext is the post content?

      what is the $open variable?

      THANK YOU!!!


      • #4
        open=> if the thread should be open/closed(you can delete this... its not necessery)
        i think that $threaddm->set_info('thread', $threadinfo); also can be deleted(just try it out*g*)

        i've just copied the code from an hack


        • #5
          Ok. perfect! that worked great. Now how can I use datamanager to update that post I just made? I'll have no problem getting the postid for that.

          Where is there more detailed information on datamanager? I swear, I can't find very much...


          • #6
            Originally posted by ragtek View Post
            you cant put it into the db with something like phpmyadmin
            thats more complex...
            Is it still possible though to add it with various SQL queries? From the research I did, it should be doable by adding some entries in the thread table and the post table.

            I personally can't use the data manager because I'm not using php for my external site.

            Am I missing something by adding data in those two tables?


            • #7
              i hope that some developer could say something to that

              i think that it doesn't go, because so no foruminformation is built new
              but i'm not sure


              • #8
                well, the reason I beleive using phpMyAdmin is not a good idea is that the entry in the thread table has the id of the firstpost and the firstpost has an id of the thread in the post table...kind of a circular reference.

                I haven't written the actual code yet, but the way i was thinking of doing it is create the thread in the thread table, then create the firstpost in the post table with the appropriate threadid and then update the thread entry with the id of the post once created.

                Obviously, i would let mySQL generate the the ids as to make sure they are no duplicates.

                Anything missing from this? The only thing that I see is for a brief moment, the thread will have no content...but this could be "fixed" by first setting it to invisible and only putting it visible when the first post is added...


                • #9
                  I just did a little bit more digging

                  and it would seem that the forum table would need to also be updated with the correct lastpost and lastthread information.

                  Am i missing something else?


                  • #10
                    You guys should really be discussing this at


                    • #11
                      I just started a new thread on here



                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.