Jump to content

Using native mysql functions instead of the module


LonelyRoad

Recommended Posts

Posted

So I have been out of the MTA scene for a while, but now I am back and looking to continue with work on my own gamemode. More to the point, the last time I did work on said gamemode the module was the only method of working with a MySQL database.

Now, evidently, it is possible to use the native SQL functions instead, and I assume for many reasons it would be a good idea to convert my gamemode to using them instead.

Anyway, more on to the point of my post...

How can I actually change my scripts now, everything I've done was using functions from the module with a 'wrapper' resource to provide ability to do queries etc. Is there any updated wrapper that provides the same functionality but with the native SQL functions? (See old wrapper here)

Posted

Not sure how you can go about converting it, but here is a simple SQL 'wrapper' I created that provides 'query' and 'execute' functionality (the only two functions you really need). SQL.Connect needs to be called in order for the connection to be established. You can change the dbConnect arguments to change it to a MySQL database.

Posted

Calling SQL connect could be done onResourceStart (addEventHandler) right?

Since you mention it, query and exec are the only two I am currently making use of, would you mind if I slightly modified your 'wrapper' and used it in my game mode? How should args be given to your functions?

Posted

Yeah, on line 7 just insert:

addEventHandler("onResourceStart",resourceRoot,SQL.Connect) 

And sure, it is open source after all.

Posted

( query, [arg1, arg2, ...] )

So, for example:

SQL.Query("SELECT id FROM accounts WHERE username = ? LIMIT 1", username) 

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.
×
×
  • Create New...