Sorata_Kanda

MySQL as a single resource?

Recommended Posts

Hey everyone,

as the title might tell you, I'm wondering what's more efficient: Having a single MySQL resource handling all the MySQL work and have something like a MySQL script in each of my scripts where I need it?

At the moment, I use a single MySQL resource which manages all the MySQL stuff, but I'm not sure if that's the right way or not. It manages really everything related to MySQL where required: admin system, ticket system, etc.

What's your opinion on that?

Thanks in advance!

Share this post


Link to post

I use one resource for mysql but i don't use mysql module i use db functions 

Share this post


Link to post

that's better for roleplay gamemodes with many scripts, because you can just use export functions for each file, but I agree with @Dimos7 to use db functions, easier to use

Share this post


Link to post

I do use the db functions too, but I'm sort of worried that my meta.xml turns to a mess due to the amount of functions I export.

Edited by Sorata_Kanda

Share this post


Link to post
2 hours ago, Sorata_Kanda said:

I do use the db functions too, but I'm sort of worried that my meta.xml turns to a mess due to the amount of functions I export.

The healthy thing to do is to make one resource and just export the functions.

Otherwise, you're just repeating code and that's useless.

Share this post


Link to post

"Healthy thing"
Sure, exports are the fastest thing on earth, even faster than a Lamborghini without an engine.
So, back on topic, they're slow af, so avoid using them if possible.
Use db* functions instead whenever possible, and in case of dbPoll, please don't use -1, just give a callback function to dbQuery instead.

Share this post


Link to post

I do use db* function, but the point of putting everything in one resource is not to create multiple database connections throughout multiple resources. Therefore you have one single resource handling MySQL stuff. But I didn't really notice any performance impact when using exported function.

Also, why should I use a callback function instead of a -1?

@Pirulax

Share this post


Link to post

yeh Create one File : like 

getMyDatainfo  ()

return  Create table info about you database host name and pass ...

 Enable Exports info in meta ( getMyDatainfo)

exports info database to all resources 

db = dbConnect( "mysql","dbname="..exports["file name"]:getMyDatainfo  () [Colum].." ....................and same for others

 

Edited by LilDawage

Share this post


Link to post
56 minutes ago, Sorata_Kanda said:

I do use db* function, but the point of putting everything in one resource is not to create multiple database connections throughout multiple resources. Therefore you have one single resource handling MySQL stuff. But I didn't really notice any performance impact when using exported function.

Also, why should I use a callback function instead of a -1?

@Pirulax

Because the server will froze till get answer from database so it better use callbacks 

Share this post


Link to post

SQLite will be better, sms me if you need help making a table with SQLite

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.