Announcement

Collapse
No announcement yet.

Adding a thread manually

Collapse
X
  • 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.

    Thanks!

  • #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();

            
    $threaddm->set_info('forum'$foruminfo);
            
    $threaddm->set_info('thread'$threadinfo);
            
    $threaddm->setr('forumid'$forumid);
            
    $threaddm->setr('userid'$userid);
            
    $threaddm->setr('pagetext'$pagetext);
            
    $threaddm->setr('title'$title);
            
    $threaddm->set('open'$open);
            
    $threaddm->set('allowsmilie'$allowsmilie);
            
    $threaddm->set('visible'$visible);

            
    $threaddm->pre_save();

                
    $threadid $threaddm->save();
                unset(
    $threaddm);
                
    build_thread_counters($threaddm);

            
    build_forum_counters($foruminfo['forumid']); 

    Comment


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

      Questions:
      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!!!

      Comment


      • #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

        Comment


        • #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...

          Comment


          • #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?

            Comment


            • #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

              Comment


              • #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...

                Comment


                • #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?

                  Comment


                  • #10
                    You guys should really be discussing this at vBulletin.org

                    Comment


                    • #11
                      I just started a new thread on vBulletin.org here

                      http://www.vbulletin.org/forum/showthread.php?t=151854

                      Comment

                      Working...
                      X