Database Manipulation

I have a few questions about database manipulation in Vanilla forums. I am using version 3.3. How do you update a record in a database in vanilla forums? I tried just using the regular algorithm used, but it does not work.


  • Phpmyadmin

  • pitkmipitkmi New

    I use MySQL Workbench

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    What is the "regular algorithm"? If you say what you have done right now, it would be easier to give advice. From within a plugin you would either use the model or a model and the methods update or setField.

    DiscussionModel::instance()->setField($discussionID, 'InsertUserID', 9);


    $someModel = new Gdn_Model('SomeTable');
    $someModel->update(['Name' => 'New Name', 'Body' = 'New Body'], ['ID' => 3]);

  • By "regular algorithm", I mean the MySQL one. Here is a link to the algorithm I used:

    I used the mysqli object oriented version. How do you use the examples you gave me? Where do you insert those codes? Is there any other codes that needs to go with them?


  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    As I've said "from within a plugin":

    If you want to extend Vanillas functionality, the cleanest approach is to write a plugin. If you have set up a basic plugin, you can put the code above e.g. in a method "public function pluginController_dbtest_create()" so that it will be executed when you visit

  • Thanks for the help R_I. I will give it a try.

Sign In or Register to comment.