Understanding the plugin connection to the database.

Discussion in 'Plugin Development' started by walknthedark, Feb 11, 2024.

  1. Offline

    walknthedark

    Hi, I'm having trouble understanding the plugin connection to the database.

    Let's say I want to create a plugin for player registration/login in which I need to make some queries. At the same time, I would like to create a second plugin that also needs to perform queries.

    My problem is that I don't want to repeat the same code in two (and more) plugins, but to use an already ready-made one (something like a library that I will create myself), only question is how to do it and if it's a good solution.

    Please give me some advice, tips. Thanks!
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    walknthedark

    Its just an example. It fits well to describe my problem, so I used it.
     
  4. Offline

    timtower Administrator Administrator Moderator

    @walknthedark How many lines do you need for a database connection then?
    Normally 10 is enough.
     
  5. Offline

    walknthedark

    I mean, is it good practice to add orm/mysql dependency to every plugin I want to preform queries in?
     
  6. Offline

    timtower Administrator Administrator Moderator

    How else do you want to do it then?
    Else you will include your own library every time.
     
  7. Offline

    walknthedark

    My plan was to create such a library, along with connect() update() query() methods etc and use it in another plugin, but I don't know how to do it
     
  8. Offline

    timtower Administrator Administrator Moderator

    Waste of time to be honest, as those are all methods limited to 10 lines.
     
  9. Offline

    walknthedark

    Got it, thanks for your help
     

Share This Page