Pivity

SQL

Last read Never
#1

In your guy's opinion, what is the easiest/securest way to add MySQL support on an addon, so it saves certain data in the DB?

Should i use MySQLOO or TMySQL4?

#2

MySQLOO https://github.com/syl0r/MySQLOO

More updated and fixes bugs it also has parts of TMySQL4 in it

Agree x 1Friendly x 1
#3
ByAnthony Fullerat 16th of July 2017 07:33:40
MySQLOO https://github.com/syl0r/MySQLOOMore updated and fixes bugs it also has parts of TMySQL4 in it

Alright Thanks, whats the best way to include it in an addon? I've seen many ways of it being done or don't you know?

#4

Create your own "Wrapper"/Handler which translates whatever you need to the MySQLOO Syntax.

Here's some Code part of my IP Geo Blocker, which gives me the ability to easily insert a new SteamID to the Whitelist. Also this shows you how to do prepared querys: 1. Create them 2. OnError&OnSucces 3.setString() 4.start()

function IPGB.Datahandler.WhitelistAddSteamID(steamId)
if not table.HasValue(IPGB.Whitelist["_steamID"], steamId) then
local query = IPGB.database:prepare("INSERT INTO ipgb_whitelist_steamid VALUES(?)")

function query:onError(err)
IPGB.Util.LogError("[DB-Error] Query failed: ".. err)
end

function query:onSuccess(data)
IPGB.Datahandler.GetWhitelistSteamID()
IPGB.Util.LogSuccess("Added " .. steamId .. " to Whitelist")
end

query:setString(1, steamId)
query:start()
end
end

Also: Use prepared query, as they are a lot safer. I created a handler for SQLite, MySQLOO and Tmysql4. And the most important thing: If you're not using perpared Statements, than escape the strings (google).

IDK if this Code is perfect as I don't really like MySQL.

Sincerely, Momox

Friendly x 1
#5

i was always a fan of tmysql4 and tbh i still am.. However support for it has gone in the trash so im forced to move to mysqloo however all my scrips will soon have an option to use one or the other

Funny x 1
#6

I've always used MySQLOO myself really and I've never had issues so I'd suggest it.

Agree x 1
Users viewing this thread
Nobody