HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

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.

Comments

  • Options

    Phpmyadmin

  • Options
    pitkmipitkmi scifi-meshes.com

    I use MySQL Workbench

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    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);
    

    or

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


  • Options

    By "regular algorithm", I mean the MySQL one. Here is a link to the algorithm I used: https://www.w3schools.com/php/php_mysql_update.asp

    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?

    Thanks!

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    As I've said "from within a plugin": https://docs.vanillaforums.com/developer/addons/addon-quickstart/


    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 yourforum.com/plugin/dbtest

  • Options

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

Sign In or Register to comment.