GTA Connected

Scripting => Module Releases => Topic started by: Vortrex on January 19, 2019, 08:58:41 PM

Title: MySQL Module
Post by: Vortrex on January 19, 2019, 08:58:41 PM
This is a simple MySQL module for those who want to use it for their server. Most of the functions have been lightly tested, but if you run into any issues please leave a reply on this topic.

Download:
https://github.com/VortrexFTW/mod_mysql/releases

Instructions:
Place into your server's "modules" folder and put "<module src="<I>module_folder_name/module_file_name</I>" />" into the modules section of your server XML. Be sure to include the folder your modules are stored in (it's relative to the main server directory) and do **not** include a file extension.
<modules>
    <module src="modules/mod_mysql" />
</modules
For Windows, you'll need to download the libmysql.dll file that goes with your server's platform and architecture. A list of these is available on the releases page, found on the link above. This file needs to be in the main server folder, not the module folder.

For Linux, you'll need to install libmysqlclient18 ... Use your distro's package manager or download from the mysql website. Unlike Windows, you don't need any extra files in the server directory for this to work.

JavaScript Example:
let db = module.mysql.connect("localhost", "username", "password", "database", 3306);
let result = db.query("SELECT id, something FROM test");
if(result.numRows > 0) {
    let row = result.fetchRow();
    console.log("ID is " + String(row[0]));
}
result.free();
db.close();

Available Functions:
connectionHandle = module.mysql.connect(string host, string user, string password, string database, int port);
resultHandle = connectionHandle.query(string query);

void connectionHandle.close(void);
int connectionHandle.affectedRows;
int connectionHandle.insertId;
bool connectionHandle.ping;
string connectionHandle.error;
string connectionHandle.info;
int connectionHandle.errorNum;
int connectionHandle.warningCount;
string connectionHandle.escapeString(string unsafeString);
void connectionHandle.selectDatabase(string database);
void connectionHandle.changeUser(string username, string password);

int resultHandle.numRows;
int resultHandle.numFields;
table resultHandle.fetchAssoc();
array resultHandle.fetchRow();
void resultHandle.free();
Title: Re: MySQL Module
Post by: Vortrex on May 18, 2019, 08:50:09 AM
  • Added query.fetchAssoc() function
Title: Re: MySQL Module
Post by: Vortrex on October 30, 2019, 08:05:02 AM
  • Updated to work with new SDK format

 
Title: Re: MySQL Module
Post by: Vortrex on March 14, 2020, 10:32:10 AM
  • Renamed the module to mod_mysql to support both GTAC and TRML
Title: Re: MySQL Module
Post by: Rhytz on December 25, 2020, 04:51:02 PM
Instructions for x64:
<module src="modules/mod_mysql_x64" />
libmysql.dll:  https://github.com/VortrexFTW/mod_mysql/blob/master/Projects/mysql/lib/x64/libmysql.dll
libmysql.dll goes in main server folder, not in the modules folder