Skip to content

Retrok253/mySQL-Framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

mySQL-Framework for Gothic 2 Online.

This framework works at top of this module https://forum.gothic-online.com.pl/topic/30-mysql/, first you have to load this module, then you'd have to load this framework, later open the config.nut file and change your MySQL credentials. Below you can see example XML file on how it should look like.

Example loading framework with module to server (Ubuntu 18.04.6 LTS)

<module src="MySQL.x64.so" type="server"/>
<script src="config.nut" type="server" />
<script src="mySQL/mySQL.nut" type="server" />

Example get function

local username = "nickname";
local password = "secretpassword";

local result = MySQL.get(format("SELECT * FROM accounts WHERE username = %s", username));

if (result) {
	// Account with specified username found.
	if (result["password"] == sha256(password)) {
		// Corrent password.
	} else {
		// Wrong password.
	}
} else {
	// Account with specified username not found.
}

Example set function

local username = "nickname";
local password = "secretpassword";

local result = MySQL.get(format("SELECT * FROM accounts WHERE name = %s", username));

if (!result) {
	if (MySQL.set(format("INSERT INTO accounts (username, password) VALUES (%s, %s)", username, password))) {
		// Insert successful.
	} else {
		// Insert failure.
	}
}

Example getAll function

local result = MySQL.getAll("SELECT * FROM accounts");

if (result) {
	foreach (i, val in result) {
		print(result[i]["name"]);
	}
}

About

MySQL framework for Gothic 2 Online.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •