@sim2511 Hard to debug without knowing which error you have
@Shake Also hard to debug, as this error can means a lot of thingâŚ
Anyway there now a branch to test this lib under fxserver, However to reduce maintenance on this lib, this version for fxserver will not support old EssentialMode API, to upgrade it will be recommended to first upgrade to an old version of this lib on the legacy version of FiveM, upgrade all your query according to the UPGRADE guide, then switch to the new version for fxserver as it respects 100% the old API.
I have a problem with my mysql-async not wanting to connect to my sql server. (OR just donât want to write anything into the database)
I followed the tutorial and searched around google and in here for an answer, sadly I found no solution.
I donât get any errors in my Server console, other than stuff with CouchDB, but thatâs no the issue.
I got the tables on the SQL, but it just donât want to implement the stuff.
For example; Lastposition. It does not save the last position for a player
I did add ârequire âresources/mysql-async/lib/MySQLââ in the server.lua of Lastposition.
Another example: Apartments; I did the same ârequire âresources/mysql-async/lib/MySQLââ to the apart_server.lua"
The menu is working, the houses are working, I just canât purchase any buildings, because it simply does not write any data to the mysql server.
I hope that someone can come up with a solution for this.
If you want to replace the parameters in log console change in /resources/mysql-async/lib/Utils.lua (0.2.2) to
function MySQL.Utils.CreateCommand(Query, Parameters, Transaction)
local Command
if transaction == nil then
Command = MySQL:createConnection().CreateCommand()
else
Command = Transaction.Connection.CreateCommand()
end
if type(Parameters) == "table" then
for Param in pairs(Parameters) do
Command.Parameters.AddWithValue(Param, Parameters[Param])
Query = AddParamToLog(Param, Parameters[Param], Query)
end
end
Command.CommandText = Query
return Command
end
function AddParamToLog(param, replace, query)
query = query:gsub("%"..param, "'"..replace.."'")
return query
end
donât do that, you will fuck up your Query, do the replacement after the query has been executed, not before here you will be vulnerable to sql injection.
I was having a hard time trying to make my gamemode use mysql connection. It was really a silly mistake. When I copied the config.lua-dist file, pasted it and renamed it, I accidentally left a space in the name and it was config .lua. I have been trying to find what was wrong for quite a while. Later I tried going through the whole setting up guide again and I noticed that the config .lua file had a space in the nameâŚ
EDIT: By the way, did you add the port configuration code for Legacy?
It will print the first ASDF but not the second FDSA
It is also successfully executing the query and adding data to the db.
Itâs also not printing the query in the console.
I seem to be running into an issue similar to @Nick78111. The query executes just fine but sometimes itâll randomly hang in the callback. When this happens, it seems to keep the connection alive and over time, causes a ridiculous amount of open connections to build up.
(This happens when I use async fetchAll, execute, and fetchScalar in the latest FXS version.)
It seems to be totally random. Just to test my sanity, I wrapped the async functions in some prints that print before the query is executed. This is what ends up happening for the same query being fired off twice, with a few seconds in between. Every query before this seemed to be successful.
The query is:
MySQL.Async.fetchScalar(âSELECT COUNT(*) FROM modelmenu WHERE identifier = @identifierâ, { [â@identifierâ] = identifier }, function(count)
// some stuff happens
end)
(It seems more common with fetchScalars, but it could just be my imagination.)
[Query Fired] SELECT COUNT() FROM modelmenu WHERE identifier = @name
[144ms] SELECT COUNT() FROM modelmenu WHERE identifier = @name
^ it worked here, but then a few seconds laterâŚ
[Query Fired] SELECT mpmodel FROM modelmenu WHERE identifier = @name
^ no longer get the [time] query message, it just seems to hang.
I do have a ton of DB calls on my server, and at times there are a lot of queries being fired off within a small time frame. Could it be related to the fact that Iâm just firing off too many queries and overwhelming things?